How can I tell which base URL to use my-app.vercel.app, my-app.com or some-other-domain.com in single project?
You variables only point on last domain I added in project. This breaks auth URL completelybecause I can’t differ between domain and tell which one to use. I can’t use req.header.host because I call function outside of request route context, it’s in utils
If there’s no way, why you offer multiple domains in project?
VERCEL_BRANCH_URL is the generated Git branch URL which is connected to the latest successful deployment from a Git branch.
VERCEL_PROJECT_PRODUCTION_URL is a production domain name of the project. It will either be the shortest production custom domain, or vercel.app domain if no custom domain is available. This will be set to a current production domain even on preview deployments.
VERCEL_URL - returns commit deployement URL with hash, not static domain generated by Vercel like my-app.vercel.app
VERCEL_BRANCH_URL - I don’t need branch URL
VERCEL_PROJECT_PRODUCTION_URL - returns my-app.com
How do I get correct URL when I open my-app.vercel.app or some-other-domain.com?
Since you’re trying to use a fixed domain, you could use VERCEL_ENV to detect the environment and set a variable in the app based on the current environment.
Can you help me understand why you need the my-app.vercel.app domain when your project uses a custom my-app.com domain? I may be able to help you find another solution if I know more about the larger goal.
I think I’ve found the right way to do it. By using different branches and assigning different domains and variables for each branch.
Probably I just tried to use it the wrong way initially, but to tell the truth, your docs lacks the examples of typical usage. I am not a backend or DevOps, hence the difficulties to figuring it out myself without proper docs.
Sorry about my frustration, and thank you for your patience Amy