arathunku

arathunku

How to match route when hostname is not known at compile time and simply matching by . is not possible?

I hope nobody will mind me resurrecting old thread instead of creating another one for very similar problem.

Does anyone have any working example where the hostname is not known at compile time and simply matching by . is not possible? Example: dynamic ad-hoc PR envs with some hash in the domain name. myapp-{{random string}}.example.comI found a workaround with replacing “host” on conn and it matched the route, but LiveView fails match in phoenix_live_view/lib/phoenix_live_view/route.ex at main · phoenixframework/phoenix_live_view · GitHub and keeps reconnecting.

Most Liked

sodapopcan

sodapopcan

(I forgot where I originally got this code from, I know it was on this forum somewhere)

hauleth

hauleth

You will need to write Plug that runs before your router and that translates from domain to path route.

LostKobrakai

LostKobrakai

The socket definition is not a plug though. All it does runs before the endpoint enters it’s own plug pipeline. Feel free to take a look at more detail here:

https://github.com/phoenixframework/phoenix/pull/6142

Last Post!

rhcarvalho

rhcarvalho

Oh yeah, that’s right! I forgot. I remember coming across your PR from other threads, as usual you know what you’re talking about :slight_smile: thanks!

In my app, I do host-to-X-header translation outside of the BEAM (for historical reasons), and use the X-header (through different code paths) for both regular routes and LiveView (plug pipeline on the relevant routes, on_mount callback on relevant LVs/live_session).

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement