Domain is routing to production branch even after setting it up for preview branch

i have deployed my pages to domain. now i want my <branchname>.project.pages.dev to be on my branch.domain.com . but the thing is, even after changing the cname record branch to point to <branchname>.project..pages.dev , its still pointing to the production branch. so right now, both my main.domain.com and branch.domain.com are pointing to the same production branch. how to fix this?
11 Replies
Walshy
Walshy7mo ago
are you using an external provider for dns?
AZipr
AZipr6mo ago
I have the same issue. The client owns the domain, and manages the DNS via godaddy. To test, We advised him to use CNAME (preview version ) on one subdomain. It still tries to load production branch. I dont know how to fix this and why this is happening. DNS propagation was successful and no issue whatsoever, but it keeps loading (and crashing) contents from prod version
Chaika
Chaika6mo ago
Walshy asked about if an external dns provider is being used, because you cannot use custom branches with external dns providers https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/
Currently, this setup is only supported when using Cloudflare DNS. If you attempt to follow this guide using an external DNS provider, your custom alias will be sent to the production branch of your Pages project.
Walshy
Walshy6mo ago
It's expected for external DNS We can't know which record you're pointing to from an external DNS provider, when you're in cf we know the record content. Outside of that, we only know we got a request
AZipr
AZipr6mo ago
Thats a bummer bcz prod and preview versions’ CNAME records are different. As a user, Its obvious that if the cname points to preview branch in Cf, it should work in similar fashion with other DNS
Chaika
Chaika6mo ago
The User's DNS flattens the CNAME record to just an IP address to send the http request to. Cloudflare would have to do an external dns lookup on every incoming request to have any idea where the hostname is pointed to, it's not part of the user's http request in anyway. When using CF DNS they can cheat since the request goes through the full proxied pipeline/resolving the cname/etc Cloudflare would have to support setting a specific hostname to a specific branch within Pages itself, then they could leverage that. Or assigning each branch a unique IP, another way to tell them apart. Maybe we'll see the former in Workers Static Assets eventually. For now, you could do something hacky with your own CF For SaaS Setup w/ a Worker, manually fetching/forwarding requests to the right branch
AZipr
AZipr6mo ago
You are right. Need to have a work around and something that doesn’t cause similar issues. I am planning to create another pages app, and make the specific preview as main branch. Keeping things simple for such clients. Done. It works! To the people out there! If you have similar problem, create another pages project, clone git repo and keep preview branch as main branch. Then redeploy and rebind the custom domain if required.
Chaika
Chaika6mo ago
I don't think you should even have to clone it, Pages for a year or so has supported monorepos/pointing more then one project at the same github repo, and you can configure the main branch as well in Pages
AZipr
AZipr6mo ago
TBH, I did the same. :bibicat:
Chaika
Chaika6mo ago
should be able to just make new pages project at same repo, change production branch to preview, done or just use Cloudflare DNS lol
AZipr
AZipr6mo ago
I wish I had control over client’s DNS or could convince them to switch to CF. Some people hate switching or learn something new

Did you find this page helpful?