Delete branch deploy in confict with a subdomain

Hello,

I suspect my branch deploys at https://staging--kometa.netlify.app are in conflict with a subdomain staging.kometa.xyz that I am serving from a different Netlify site. Any chance to have https://staging--kometa.netlify.app deleted please?

Thank you!

hey @chrisjansky , our branch-to-subdomain mapping is automatic, so a staging subdomain can only be populated by deploying a branch called staging - if you are using Netlify DNS to point to that subdomain, that is.

Are you using Netlify DNS?

Hello @perry,

Thank you for the quick reply. Yes, I am using Netlify DNS. I actually have two Netlify sites that each serve the master and staging branch only, respectively. I initially had just one site with the branch deploy enabled, but thought of making two sites so I can have different env variables for each.

In Netlify DNS I put a CNAME record from dev.kometa.xyz to kometa-dev.netlify.app (the site name) hoping it would actually lead to the other site rather than the staging branch deploy.

Is there a better way to go about having separate env variables for those branches?

Thanks!

EDIT: I think I can serve those variables using context in netlify.toml, but those do not get read by Netlify Functions, correct?

Hi, @chrisjansky. If you need different environment variables for different branches and those environment variables are to be used in functions (both of which appear to be true), then using two sites is the best workaround at this time.

Now, the important thing to understand about how sites are linked to domain names at Netlify is that this is 100% determined by the site settings.

The DNS records only point the domain names to the IP addresses of Netlify’s ADN - nothing more. The DNS records themselves do not determine the site shown in any way at all. After the IP address resolution occurs, the site shown in always 100% determined by the site setting at Netlify (Site Name > Settings > Domain management > Custom domains).

Because you used the branch subdomain for a site and now that site is linked to the branch subdomain until the site is deleted.

The only way to delete a deploy is to delete the site itself. That is the only solution at this time.

What could have happened (but didn’t)

Note: I’m using example.com in place of the real domain name in these examples.

You could have created a site using the custom domain example.com and you only used the branch “production” for that site then no branch subdomain would be applied.

Then you could make a second site where the production branch at Netlify was “staging” and add the custom domain staging.example.com. This is not the branch subdomain feature. You are using a production branch of “staging” and assigning a custom domain.

This allows you to set two different sets of environment variables in the web UI for the two branches.

What actually happened

You made a site and then enabled the branch subdomain feature for it. This permanently links staging.example.com to this original site.

You have tried to create a new site and assign the branch subdomain to it (staging.example.com). However, because it is already being used by the site above, this setting doesn’t actually work.

The solution

This isn’t a great solution but it is the only solution that exists at this time:

  • Delete the original site and then recreate it with all the same setting - except for one. Do not enable the branch subdomains on the newly created site.

This is the only solution because there is no other way to delete deploys at Netlify. Deleting the entire site is the only way do delete a deploy at this time. We cannot just delete the branch deploys because the only way to do so is completely removing the site itself.

So, the only way to delete the branch subdomains enabled for a site is to delete the site itself. If you then recreate the site (same site name kometa) and link it to the same repo and branch - it will delete all the previous deploys at Netlify.

You will completely lose your deploy history with this solution but it will work. Now the branch subdomain is no longer associated with the new site and the other site using that subdomain as the primary custom domain (not a branch subdomain) will start working.

If there are questions about any of this, please let us know.

1 Like

Hello @luke,

Thank you for a very, very comprehensive answer! This is all the info I need—marking as solved.