Custom domain with Pages AND R2?

Fairly new to DNS, Cloudflare etc.

How would I go about adding the same custom domain to Pages and R2?

My name servers from domain provider are connected to Cloudflare.
Initially I added a custom site to my public R2 bucket for CDN purposes.

I then decided to use Cloudflare pages to host my site.

I attempted to connect a custom domain via the Pages Custom Domains tab. This didn’t work, and I discovered the reason was because R2 had already added a CNAME record with www.

Once I deleted that CNAME record, I could add a CNAME record to Pages with @.
However, I still need the files in the public bucket to be accessible via the root domain.

Is it possible to connect the same custom domain to Pages and R2 concurrently? If so, how would I go about this?

Many thanks.

No, you can’t use the same hostname for Pages and R2, you’d have to put at least one of them on a subdomain.

If you really want both to “use” the same hostname for both, you could deploy a Worker that uses your apex domain and routes requests either to Pages or R2.


Thanks for your help. I’ll dig into that document.

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