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

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
mnkhod
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
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
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews