platforms icon indicating copy to clipboard operation
platforms copied to clipboard

Use custom domain for Preview Deployments

Open thomaslenaour opened this issue 1 year ago • 3 comments

Hello, is it possible to use a custom domain for preview deployments ? I'm having trouble configuring this.

Here is what I want to do:

Preview Deployments

Domain : preview.mydomain.com Visit preview.mydomain.com then see Home Page. Visit app.preview.mydomain.com then see App. Visit {ORGANIZATION}.preview.mydomain.com then see the specific organization page.

Production Deployments

Domain : mydomain.com Visit mydomain.com then see Home Page. Visit app.mydomain.com then see App. Visit {ORGANIZATION}.mydomain.com then see the specific organization page.

Has anyone managed to make it work like this?

Thanks in advance!

thomaslenaour avatar Mar 12 '24 06:03 thomaslenaour

Yes, that works without any issue. What's your error that you get?

My domain config:

  • www.preview.mydomain.app redirects (308) to preview.mydomain.app
  • *.preview.mydomain.app is assigned to my branch preview
  • preview.mydomain.app is assigned to my branch preview

My env config:

  • NEXT_PUBLIC_ROOT_DOMAIN=preview.mydomain.app

Xennis avatar May 19 '24 20:05 Xennis

Yes, that works without any issue. What's your error that you get?

My domain config:

  • www.preview.mydomain.app redirects (308) to preview.mydomain.app
  • *.preview.mydomain.app is assigned to my branch preview
  • preview.mydomain.app is assigned to my branch preview

My env config:

  • NEXT_PUBLIC_ROOT_DOMAIN=preview.mydomain.app

I can't seem to get this to work. how is it that you are chaning your NEXT_PUBLIC_ROOT_DOMAIN? wouldn't that break it for the first use case?

joshualinog avatar Aug 29 '24 20:08 joshualinog

check out this guide

https://vercel.com/guides/set-up-a-staging-environment-on-vercel

when @Xennis says this:

My env config:

  • NEXT_PUBLIC_ROOT_DOMAIN=preview.mydomain.app

I took this config and i added it in the environment variables UI tab of the project's settings in vercel. I created a preview environment variable and I made it match the branch i named preview

joshualinog avatar Sep 03 '24 21:09 joshualinog