reverend_paco

reverend_paco

I am deploying an Elixir application behind an Nginx proxy (multiple Elixir applications actually) and am having some issues specific (I think) to live_redirect.

I have

  1. changed the url in my config.exs by adding the path as such: url: [host: "localhost", path: "/campaign"]
  2. prepended the base-url to the app.js as such: let liveSocket = new LiveSocket("/campaign/live", Socket, {params: {_csrf_token: csrfToken}})

I have another application that uses LiveView that works fine, but this campaign application, which another developer has developed, manifests the problems.

In the backend I see:

[error] an exception was raised:
    ** (ArgumentError) cannot invoke handle_params nor live_redirect/live_link to "https://[ELIDED]/campaign/dashboard/nonode%40nohost" because it isn't defined in CampaignsLiveWeb.Router
        (phoenix_live_view 0.12.1) lib/phoenix_live_view/utils.ex:209: Phoenix.LiveView.Utils.live_link_info!/3
        (phoenix_live_view 0.12.1) lib/phoenix_live_view/channel.ex:600: Phoenix.LiveView.Channel.verified_mount/4
        (phoenix_live_view 0.12.1) lib/phoenix_live_view/channel.ex:34: Phoenix.LiveView.Channel.handle_info/2

I am wondering if anyone has seen anything similar to this before, and can give me a hint as to where I might explore?

Again, I have successfully deployed another LiveView application using the above 2 points, so I know that nginx is properly passing/upgrading the websockets. I feel that this is related to the issue here, although in my case, I know what the top-level URL is going to be and am not using dynamic re-writing.

Thanks,
Daniel

Showing Posts 1 to 5

sfusato

sfusato

Are those liveviews defined at the router level?

However, only the LiveViews defined directly in your router and use the “Live Navigation” functionality described here. This is important because LiveViews work closely with your router, guaranteeing you can only navigate to known routes.

Phoenix.LiveView — Phoenix LiveView v1.2.5

reverend_paco

reverend_paco OP

Yes, they are.

 11   scope "/", CampaignsLiveWeb do                                                                                                                                            
 12     pipe_through :browser                                                                                                                                                   
 13                                                                                                                                                                             
 14     live "/", PageLive, :index                                                                                                                                              
 15                                                                                                                                                                             
 16     live "/attempts", AttemptLive.Index, :index 
...
67    end                                                                                                                                                                       

I’ve been peeking at the phoenix_live_view/util.ex (the live_link_info! method, in particular) and I think if pass the endpoint in there, I could grab the config-ed :url key and remove the proxy path there. Gonna see if I can hack this to understand what’s going on.

sfusato

sfusato

How are you calling live_dashboard in router.ex ?

live_dashboard("/campaign/dashboard")?

reverend_paco

reverend_paco OP

Sorry, that was a stacktrace from when I went to the dashboard, I was getting it the same way with other URLs:

81    if Mix.env() in [:dev, :test] do                                                                                                                                          
  1     import Phoenix.LiveDashboard.Router                                                                                                                                     
  2                                                                                                                                                                             
  3     scope "/" do                                                                                                                                                            
  4       pipe_through :browser                                                                                                                                                 
  5       live_dashboard "/dashboard", metrics: CampaignsLiveWeb.Telemetry                                                                                                      
  6     end                                                                                                                                                                     
  7   end         

I am noticing one thing in my codebase that might be problematic (and might have nothing to do with this particular error or is the problem). In the eex templates, I see that the action is using a old-style to: action,

 27         <td><%= live_redirect campaign.audience.name, to: Routes.audience_show_path(@socket, :show, campaign.audience) %></td>                                              

instead of the Routes.live_path that I see in the documentation.

I wonder if this might be related.

reverend_paco

reverend_paco OP

Well, my hack worked. I changed utils.ex and channel.ex and static.ex to pass in the endpoint to the live_link_info and then used the path to remove the prefix coming in from websocket and things started working.

Feeling proud of myself, I wanted to see if I could contribute it back and checked on github and saw that this has been fixed with the following patch: Consider script_name on client URLs, closes #805 · phoenixframework/phoenix_live_view@06b3e81 · GitHub

So if anyone is having a similar problem, grab the latest from master (I was on version 0.12.0)

EDIT: if you don’t want master, it looks like this fix is on 0.13.0

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews