Is this the expected behaviour?
I would have expected it to be set to be custom domain.
Is this the expected behaviour?
I would have expected it to be set to be custom domain.
Yes, this is expected. Here you can see the list of env vars and their expected values.
Is there a way to get the custom domain?
Hi @TedMeftah ,
Render services can have many custom domains, so we don’t specify it as an environment variable. The best way to detect this is to look at the Host
header in the HTTP request, which will let you know which domain a request is meant for.
Would this approach work for you?
Hi @dan, we also expected to have access to the custom domain URL through the environment variables, and I don’t think the Host
header solution you’re suggesting is a valid workaround.
Our use case is that the backend service needs to know the frontend base URL to use it for links embedded in customer emails. I could hardcode the frontend base URL as an environment variable in the backend service, but then I would lose the ability to have that env var automatically populated in preview environments.
Ideally, I would like to have an env var that defaults to a custom domain when available and falls back to the onrender
URL otherwise.
Edit: I just realized this thread is over a year old, I thought it said “April 21st” not “April 2021” . I’d love to know if there’s a workaround though since otherwise I’m either sacrificing preview environments or custom domain URLs in production (which is a no-no).
Hi Ian,
Services can have any number of custom domains, so auto-creation of custom domain environment variables feels like it would need further consideration/configuration, however please feel free to open a feature request on the feedback site.
Maybe a workaround for the Preview Environments could be to utilise the “initialDeployHook” to run a script that uses the API to carry out the configuration updates you need?
Alan
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.