reverend_paco
Phoenix LiveView Websocket proxy and live_redirect
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
- changed the
urlin my config.exs by adding thepathas such:url: [host: "localhost", path: "/campaign"] - 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
Marked As Solved
reverend_paco
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
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










