Branch subdomain with custom domain not working

Site name: finta-api-redirect
Site domain: api.finta.io

I have two branches, main and staging both with automatic deployments. My main branch is set to https://api.finta.io and my staging branch is set to https://staging.api.finta.io using the Branch Subdomains feature.

I am able to access https://api.finta.io (main branch) without any issues. However, when I try to access https://staging.api.finta.io, the request fails completely. Weirdly enough, if I go directly to the staging branch’s branch deploy site (https://staging--finta-api-redirect.netlify.app) it works perfectly fine. Seems to be an issue with DNS then?

Thanks for any help.

If you can you provide the following information, you can get better help.

  • What’s the SSG/framework that you are using ?
  • Are you using Netlify DNS or your domain registrar’s DNS ?
  • Is your code publicly available (on GitHub, Gitlab etc.) ? If yes, please provide a link to the repo.

This information is not relevant to the OPs issue @Sidharth.

Branch subdomains are only available when using Netlify DNS, ergo OP is using Netlify DNS.

Again, this information is not relevant to the OPs issue.

@coelmay , let me justify why did I ask about SSGs in the context of Hugo (applies to other SSGs as well). If you don’t set the baseUrl correctly for your staging site, then you are bound to get error. In other words, you can’t use the same build command both for main branch (production) & staging. For staging, the command should be hugo --baseURL='https://staging.example.com

This is exactly the reason for which I asked for a link to GitHub repo. So that, if she is not using different baseUrl for the staging site, I would have recommended her to do so creating a netlify.toml with the following in it:

[build]
publish = "public"
command = "hugo"

[context.production.environment]
HUGO_VERSION = "0.86.0"

[context."staging"]
command = "hugo --baseURL='https://staging.example.com'" 

This is the reason why I asked for SSG & link to repo, so that I can check whether these are implemented.

But you are correct regarding DNS, since branch deploy is available only with Netlify DNS.

I am using Netlify’s DNS. Turns out I just needed to wait for a few hours for everything to propagate. It’s up and running now.

1 Like

So glad everything is working, @TaylorFacen! Thanks for confirming!