Use custom domain for Preview Deployments
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!
Yes, that works without any issue. What's your error that you get?
My domain config:
-
www.preview.mydomain.appredirects (308) topreview.mydomain.app -
*.preview.mydomain.appis assigned to my branchpreview -
preview.mydomain.appis assigned to my branchpreview
My env config:
-
NEXT_PUBLIC_ROOT_DOMAIN=preview.mydomain.app
Yes, that works without any issue. What's your error that you get?
My domain config:
www.preview.mydomain.appredirects (308) topreview.mydomain.app*.preview.mydomain.appis assigned to my branchpreviewpreview.mydomain.appis assigned to my branchpreviewMy 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?
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