In a normal Phoenix app. the Router.Helpers generate correct urls, e.g.
Routes.user_confirmation_url(conn, :confirm, token)
will output https://myapp.com/user/confirm/?token=token
.
When I deploy an app to Gigalixir using Elixir releases, I have to specify (as per docs https://gigalixir.readthedocs.io/en/latest/modify-app/releases.html#modifying-existing-app-with-elixir-releases):
url: [host: nil, port: 443]
in config/releases.exs
.
And this results in incorrect URLs being generated (they come out as https://localhost:443/user/confirm/?token-token
).
I can workaround this for now, by setting a new ENV var, say, BASE_PATH=https://myapp.com
and generating URLs like this:
Routes.user_confirmation_url(%URI{path: System.get_env("BASE_PATH"), :confirm, token)
but I don’t like having to repeat this code in many places.
So I have 2 questions:
- Is there some config I can change to make Elixir releases on Gigalixir use correct base path for URLs?
- Is there some way to “hijack” the URL-generating function that will let me replace “localhost” string?
Thanks in advance.