Custom URL for preview deployments

Hey! Is there a way to use my custom domain instead of .pages.dev for preview URL? I'm using Clerk for auth and when I test my production preview via CF Pages (with a *.pages.dev URL), Clerk fails to load because it's not on my custom domain. I want *.pages.dev to be *.preview.mydomain.com Should I use a reverse proxy or maybe a CF Snippet to make this works?
3 Replies
i40west
i40west5d ago
You can point a custom domain to a git branch, so it will always be the latest preview deployment of that branch. So if you have a branch dev then you can have dev.example.com always be the most recent deployment of that branch. https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/
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.
Armand
ArmandOP3d ago
Hey, thanks for your response. I finally did it with a nginx reverse proxy to get <branch>.previews.example.com -> <branch>.myproject.pages.dev Works very well!
burroughs06
burroughs063d ago
@Armand I'm actually working on this same exact scenario. Can you elaborate on your reverse proxy configuration? Where did you host the Nginx server?
Want results from more Discord servers?
Add your server