How to deploy with aumatic custom domain?
techacademialendaria
PROOP

a year ago

Hey everyone, hope you doing well. I've just activated the PR Environments and need to set some variables that use the domain like NEXTAUTH_URL and BROWSER_API that uses the domain. In this case I need some way to automatically generate this domain and apply in the env vars in a form that not affects my production environment.
Does someone can help me?
Thanks a lot!

Solved

1 Replies

a year ago

Hey @techacademialendaria!

For this use case, I think you can take advantage of the Railway-provided variables which are environment variables that are made available on every deployed service: https://docs.railway.app/reference/variables#railway-provided-variables

For your use, you may need `RAILWAY_PUBLIC_DOMAIN`. So if you currently have your variable hardcoded like this (for example) -

NEXTAUTH_URL=https://academialendaria.ai/auth

then you'd update it to -

NEXTAUTH_URL=https://${{ RAILWAY_PUBLIC_DOMAIN }}/auth

If you need it to resolve to the domain of another service, it would be something like -

NEXTAUTH_URL=https://${{ backend.RAILWAY_PUBLIC_DOMAIN }}/auth

Using this pattern should make the variable definitions dynamic in your PR environments. Let me know if this helps


Status changed to Awaiting User Response Railway over 1 year ago


Railway
BOT

7 months ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 7 months ago


Loading...