Preview branch, custom domain not supported

When adding a custom domain for a preview branch using external DNS, this page states that custom domains are not supported for external DNS. https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/ Why does this limitation exist? Are there any ways to work around this functionality?
Cloudflare Docs
Add a custom domain to a branch · Cloudflare Pages docs
In this guide, you will learn how to add a custom domain (staging.example.com) that will point to a specific branch (staging) on your Pages project.
4 Replies
Chaika
Chaika9mo ago
Think about it from a DNS standpoint User sends request to resolver to resolve A/AAAA record -> receives IP from following CNAME User sends request to resolved IP. It sends the Host header CNAMEs are a sort of client-side thing, if it helps to think of it that way The only way CF Pages would know the exact CNAME that the host is pointing at is resolving it themselves which would be slow/relying on your potentially slow external dns, etc. And in some cases, some providers flatten cnames already to a/aaaa records which would make that entirely impossible (the other critical bit here is the resolved IPs used are the same for every subdomain/they don't issue a pair per subdomain or anything, so that can't be used to identify the one to serve either) Throw in the fact too that Pages is an extremely generous free offering, works way better when you're already using CF as you can use their existing CDN options like redirects/waf/etc, and is a good way to get people onto the platform
jman
jmanOP9mo ago
I'm not sure I understand why these would mean its not possible... I just spent a few minutes trying to apply this behavior on other platforms (like Vercel) and it worked perfectly? Are there ways to get this to work on Cloudflare without moving my DNS there?
Chaika
Chaika9mo ago
I haven't messed around with Vercel before but I'm guessing they either let you select the branch per custom domain or assign different IPs to each branch CF does the Custom Domain stuff leveraging the fact they are the DNS Provider and always know where the CNAME is pointing without needing to lookup externally You could do something hacky where you use CF for SaaS and have your subdomain as a Custom Hostname, pointed to a Worker which is fetching the preview domain directly, but you'd be paying for each request as a Worker Invocation. Nothing native eitherway though, their way of doing it is just different and requires using CF DNS
jman
jmanOP9mo ago
Ok thanks anyway for the help!
Want results from more Discord servers?
Add your server