Setting Up Custom Domains for Different Branches in Cloudflare Pages
I'm currently utilizing Cloudflare Pages and have successfully integrated my project directly with GitHub. Within my repository, I manage two primary branches: 'main' for production and 'stage' for testing purposes.
For my production environment, I've successfully configured a custom domain, specifically www.mywebsite.com, and everything is functioning as expected. However, I'm encountering challenges when attempting to establish a custom domain for the 'stage' branch. Ideally, I'd like to have a domain like stage.mywebsite.com for this testing environment.
My question is: How can I go about specifying a custom domain for the 'stage' branch in Cloudflare Pages? I've reviewed the documentation and guides, but I haven't found a clear solution for achieving this configuration. Is it even possible to have distinct domains for each branch, such as having different domains for production and testing environments?
Your guidance and insights into this matter would be greatly appreciated. Thank you for your time and assistance.
4 Replies
First, add
stage.mywebsite.com
as a custom domain to the Pages project. A DNS entry will be created automatically, pointing to the main site. Go to your DNS settings and edit the CNAME to point to the staging branch's pages.dev URL, like staging.project.pages.dev
. (Ignore the warning it may give you.)Thanks, works fine!
Who did your diagrams for you
Those are dope
Those sure are. I want to know about those tool too