Branch subdomain with wildcard CNAME

Hi Netlify Support,

I’m using Netlify DNS and have a wildcard CNAME record that points to prod branch site.
*.mydomain.app -> myapp.netlify.app
I also have a subdomain called test that points to my test branch site
test.mydomain.app -> test–myapp.netlify.app

In Deploy context, my production branch is prod and I also created branch deploys for my test branch as well.
prod -> myapp.netlify.app
test -> test–myapp.netlify.app

I was hoping test.mydomain.app would use the build/deploy of test–myapp.netlify.app site. Instead, it seems to pick up the build of myapp.netlify.app site.

This I can confirm, because the API environment variable (in my app source code) I set the value to api.myapi.com for production build (myapp.netlify.app). Whereas the same variable is set to api-test.myapi.com for test build (test–myapp.netlify.app)

UPDATE: If I visit test–myapp.netlify.app directly, I can see that it is using the correct API environment variable (api-test.myapi.com). Seems like the wildcard CNAME is taking precedence over explicit subdomain test.

So the issue is my branch subdomain test.myapp.app is not pointing to the right API server.

Can you please help with what is missing here?

Thanks,

Hi, @sthamm. We are happy to troubleshoot to find out what is happening. However, to do this, we need to know the actual URLs being tested. Would you please let us know what domain name you are using and what branch you expect to be deployed at that domain name?

You can private message (PM) that to one of our support staff and I’ve confirmed that PMs are enabled for your community login. Note, that only one person can see the PM and this will likely mean a slower reply than posting the information publicly. Please feel free to reply to however you prefer though.

Hi, @sthamm. Thanks for PM-ing the site details. For the site in question, branch subdomains are not enabled under: Site Name > Settings > Domain management > Branch subdomains.

Also, the DNS records never control what site is shown. They control which IP address the traffic is sent to but which site is shown for a domain name is controlled at the HTTP level not the DNS level. In other words, this is controlled by the site settings and not the DNS settings.

Would you please at that custom domain for the branch subdomain for this site?

Note, currently other branches are disabled for this site (under Site Name > Settings > Build & deploy > Deploy contexts). You will likely need to enable this branch there as well.

If this doesn’t resolve the issue, please let us know.