By default, Netlify generates a PR’s deploy preview URL as a subdomain xxx.netlify.app
, an example being https://deploy-preview-123--sitename.netlify.app
.
However, I am hoping to change it to a CHILD subdomain xxx.sitename.netlify.app
, something like https://deploy-preview-123.sitename.netlify.app
.
Is this possible somehow?
Thanks
Hi, @jack-yang-dsny. The reason our service does not do this is that we would then need to create a unique SSL certificate for each site. For example these six domain name below:
deploy-preview-123--siteone.netlify.app
deploy-preview-789--siteone.netlify.app
12297e9dbaf6e97aab83f9d0--siteone.netlify.app
deploy-preview-456--sitetwo.netlify.app
deploy-preview-789--sitetwo.netlify.app
92297e9dbaf6e97aab83f9d0--sitetwo.netlify.app
That is two sites and six deployment URLS. However, a single SSL certificate for *.netlify.app
covers all domains. If we were to add this as an option under the site subdomain, then a unique SSL certificate would be required for each site (*.siteone.netlify.app
, *.sitetwo.netlify.app
, etc.).
Our support team can enter a feature request for this but I wanted to explain why we don’t do it already.
Also, you can do something similar to this when using Netlify DNS under the site’s custom domain (as a subdomain under the primary custom domain for the site). However, it only works for branch subdomains at this time and there is documentation about that feature here:
https://docs.netlify.com/domains-https/custom-domains/multiple-domains/#branch-subdomains
We have an open feature request for this custom domain subdomain feature to also work with the deploy previews and the deploy id version of deploy URLs.
To use example.com
as the primary custom domain, this means making these two URLs:
https://deploy-preview-123--sitename.netlify.app/
https://12297e9dbaf6e97aab83f9d0--sitename.netlify.app/
be available at:
https://deploy-preview-123.example.com/
https://12297e9dbaf6e97aab83f9d0.example.com/
Again, that does already work for branch subdomains and the feature request is to extend that support to the deploy id and deploy preview URLs as well.
I’ve cross-linked the feature request to this topic so if it does become possible we will notify you about it here.
Back do your question about making this happen under the sitename.netlify.app
subdomain there is no feature request for that but our support team can create one if that is your requirement. If instead the custom domain feature request will meet your requirements, that existing feature request is now linked to this topic for follow-up.
If there are other questions or if the new feature request would be better, please do reply here anytime.
Thank you, @luke, for the detailed explanation.
This looks like the earliest hope we can expect.
Back to my original question, the purpose behind was to share session (by cookie) between various deploy previews. Since our app is private, every preview requires a sign-in. We wanted to avoid this and tried with writing session cookie to parent domain (.netlify.app
), but failed. This led to the idea of child subdomain in my question. Since the feature request is not supported at this moment, @luke, I really appreciate it if you can possibly share any ideas on sharing session between previews.