What determines the primary domain of a deployed project

How can I control the “primary domain” when adding multiple third-party domains to my Vercel project called Virtoura. It’s built using Next.js and using Gel Auth with email/password and Google OAuth providers. I would like www.virtoura.app to always be the “primary domain”.

I’ve noticed that when I add a new third-party domain (e.g., tour.innspace.nl) to my project, it automatically becomes the “primary domain” for the next deployment. Now when users try to signup it results in errors because the allowed redirect URLs for authentication no longer match, as this now uses the tour.innspace.nl instead of www.virtoura.app, which is registered as allowed redirect urls (though nothing breaks until a new deployment is done). The www.virtoura.app domain should remain the primary one, with third-party domains only serving specific paths, for example tour.innspace.nl/show/seo-friendly-project-name for white-label purposes. My clients go through the guided domain verification by putting the CNAME and the custom value in the DNS records of their domain/hosting provider.

Is the above statement/assumption correct? Or might it be related to tour.innspace.nl being the “last added” shortest url? As stated in the docs for the VERCEL_PROJECT_PRODUCTION_URL environment variable?

AFAIK there no concept of a “primary domain” via the Vercel dashboard? I’m looking for a solution to always use www.virtoura.app as the primary domain while being to add third-party domains without breaking auth. Any guidance on dashboard settings or configurations would be appreciated, or could I do this programmatically?

Similar topic explaining the same issue with auth breaking: How to differ between multiple domains in project? #11872

Hopefully I’ve explained it well enough, if there’s any questions please ask!


Separate but associated question: How can I best only allow the path /show/seo-friendly-project-name to be accessed through a third-party domain? All other non-matching paths should redirect to www.virtoura.app. Is this something I can control with a vercel.json and properly configured rewrites section?

The domain troubleshooting guide can help with most custom domain configuration issues. You might be able to use that guide to solve it before a human is available to help you. Then you can come back here and share the answer for bonus points.

You can also use v0 to narrow down the possibilities.

Nobody got any idea about this or hasn’t faced the same issue?

It seems the solution was simple, I just set my own env variable something like NEXT_PUBLIC_BASE_URL to my domain, and use that instead of VERCEL_PROJECT_PRODUCTION_URL, apparently that one is “unstable” i.e. not always my own main domain during deployments…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.