How to expose branch preview URL to public domain (branch.myapp.pages.dev -> branch.myapp.com)
Hi folks, I have a staging branch that is is routed to the branch preview URL like this
staging.myapp.com -> staging.myapp.pages.dev
. How would you do the same for all preview branch urls? I'm looking for something like this: [branchname].myapp.com -> [branchname].myapp.pages.dev
.
4 Replies
can't do wildcard, have to do one at a time/per branch. Or use a Worker to proxy requests to the pages.dev (would have to pay for each request as a invocation though)
Cool, I guess I can make it work with one main staging branch. I added this record, but when I go to this domain https://staging.yupty.live/ I get a 522 error. The pages it points to (https://staging.yupty-front.pages.dev) loads fine

you have to add it as a Custom Domain in your Pages Project first
and then change the cname it makes for you
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.