slouchpie
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 Using Elixir Releases — GIGALIXIR 1.4.0 documentation):
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.
Trending in Questions
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
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
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
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
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
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
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
slouchpie
My current workaround, for anybody else with the same problem.
Make a Gigalixir configuration variable
BASE_PATHwith value likehttps://app.staging-myapp.com.Then make a module (to keep the “hack” logic in one place):
Then change any URL generating code like this:
into this:
luckywatcher
I don’t have experience with Gigalixir, but I have ran into this problem before. The URL generation code includes two variations:
*_urland_path. The*_urlone that you are using requires the host url to be specificied in theconfig/releases.exsfile. The*_pathvariation does not.Quoted from Routing — Phoenix v1.8.8 and Routing — Phoenix v1.8.8
…
TL;DR try using
Routes.user_confirmation_path(conn, :confirm, token)instead ofRoutes.user_confirmation_url(conn, :confirm, token).I presume you are using this as an email sent in a link for user email confirmation. If that’s the case, I’d recommend prepending the
BASE_PATHthat you have set up to the path. I’d say that’s still cleaner than leveraging%URI{}and overriding thepathkey.You may need
System.get_env("BASE_PATH") <> Routes.user_confirmation_path(conn, :confirm, token)mhanberg
I’m not sure why the docs say to set that to nil. I looked at an old app i deployed to gigalixir and this is what I had
slouchpie
Using
_pathprovides correct relative path but without the domain part.I don’t like your suggestion of prepending
System.get_env("BASE_PATH")everywhere I need it.I would rather have a dedicated module that acts as a single source of “realisation” for what is really a hack. It makes future modification and understanding easier, especially for posterity (other devs).
slouchpie
This is good to know but I wonder
LostKobrakai
This is because the config is not the only place do derive the domain from, but it might just be wrong in telling you to set it to
nil. It likely should just skip the:hostkey completely.The
conndoes hold the domain the app is accessed by, which is then used by the helper to build up the full url. This is especially useful for places like gigalixir, where it’s likely that the app is accessable via multiple domains. What this will prevent however is usingMyApp.Endpointwith those helpers to create full urls.There is a place, which needs an explicit
host: nil, which is forforce_ssl:https://github.com/LostKobrakai/hex-bobs-list/blob/4e3acc34f62cabf332d9120c3334bd587bf60fbf/config/prod.exs#L11
slouchpie
To summarise, the
hostconfig should be eithernilor omitted.This means the route helpers won’t generate correct URLs so I will keep my current workaround.
mhanberg
If you’re using a custom domain, I would just hard code the domain in the config.
josevalim
I don’t understand why they are asking to set it to
nil, perhaps you should e-mail support and ask for clarifications.The thing is most apps are running behind a proxy, Gigalixir is no different, and inside the proxy, you are typically running on localhost. So here is how it works:
So if you don’t configure the host, the app is correct in thinking it is running on localhost. We could use the
X_FORWARDED_FORheaders to figure out the actual host but that has security implications when read and it is not behind a proxy. So my suggestion is to explicitly set the:hostto your actual host instead of nil in your config files. You can either hardcode it or use an environment variable.TL;DR: don’t use nil, set it to your actual host.
slouchpie
The same app is deployed on different domains (using different Gigalixir accounts).
Because “paid” Gigalixir accounts cannot have “free tier” apps, I have 2 Gigalixir accounts - one paid account for live apps and one free account for “staging” versions of the same apps.