Attach a subdomain to a specific branch (DEV) in Cloudflare Pages

Hello
I noticed our DEV branch is getting a new random subdomain for each deployment
I wonder if it’s possible to set a custom subdomain for DEV branch like we did for MAIN branch in Cloudflare Pages?

2 Likes

Hi!

It can be done, although it’s not at all documented.

Two steps:

  1. add the domain you want to use as a custom domain in Pages, the normal way to add any domain.
  2. point the CNAME to branch-name.[subdomain].pages.dev.

It works for me just fine, you might need a little bit of time for the certificate to issue.

3 Likes

it seems to work … but in fact it’s just serving the prod version :frowning:

It definitely does for me as the “main” brach is non-working (it’s still the default repo), but the “development” one is.

Can you post a screenshot of the DNS records + the Pages Custom Domains configuration?
Do redact private infos your don’t want public.

It’s seems as a new user on this forum I’m not allowed to post images …

So I will provide details in text here:
my main branch is on subdomain “dash” and the CNAME is pointing to “elestio-dashboard.pages.dev”
I have added the CNAME “dash-dev” pointing to “dev.elestio-dashboard.pages.dev” because my other branch is named “dev”

In “pages custom domains” I do see dash.elest.io and dash-dev.elest.io both active

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.