Migrating from Amplify to Cloudflare Pages
I'm migrating my frontends from Amplify to Cloudflare Pages. Under Amplify, there's a way to easily connect domain -> branch that is being deployed. For example:
staging.site.com
-> develop
site.com
-> master
How do I do the same in Cloudflare Pages?8 Replies
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.
for your master/production branch you can just add the custom domain normally and it'll just point there by default
Oh I see! To confirm:
1. Create custom domain
2. Overwrite the DNS that is setup with
${branch}.your-project.pages.dev
because it will point to your-project.pages.dev
first?yeah basically. and your domain must be managed by CF to access this feature. I moved my domain over from namecheap to CF for this feature alone.
Was your domain live? Seems like there will be downtime since it takes some time to register a custom domain.
My current setup (Cloudflare DNS + Amplify):
Cloudflare DNS
- site.com -> amplify url
based on your original question doesn't look like you need to register a custom domain though.
If your domain is
site.com
you can map different branches to different subdomains. so www
is a sub domain of www.site.com
and so is staging
is the subdomain for staging.site.com
but it's all the same domainSorry if my question wasn't clear but it seems like Pages only separates between
production
and preview
.
1. Separate domain for each environment (this can be done)
staging.site.com
load.site.com
production.site.com
2. Env vars
What if I want to set different env vars for each preview environment? Seems like preview will be shared across staging
and load
yes that's correct. cloudflare only has production and preview environments
I'm making do with that
I have
app.site.com
and staging.site.com