I have a problem with getting subdomains working on Cloudflare Pages. I have tried looking for the posts here with similar issues but none of the solutions on those topics seem to be working with my case. That’s why I’m asking for help if someone might figure out what I’m doing wrong here.
So I have my domain from Namecheap added to Cloudflare Pages and the base domain with https is working just fine. The base domain has CNAME record to …pages.dev domain that is offered by Cloudflare. I have tried adding www CNAME record to target that same …pages.dev domain but I’m greeted with error 522 - connection timed out. I also tried adding www CNAME record to my base domain but that has the same outcome. I’m quite sure that I have to set the target of subdomain to the …pages.dev because my base domain is also set to target that one. However I just can’t seem to get this working.
I have proxied both the base domain and sub domain through Cloudflare. Also my SSL/TLS encryption mode is set to full.
May I ask are you trying to get
www.sub.domain.com or rather
sub.domain.com (notice the difference www before sub then domain name dot tld)?
www for your naked domain name
You should have two domains listed (or two buckets?) under custom domains to make it work, if using some 3rd-party like Amazon Web Services for static website, etc.ž
Or rather, the CNAME www should point to your naked (root domain) which goes to the pages dev as far as I understand.
Hi Fritex and thank you for replying.
I am trying to set up the www for the naked domain (domain.com), so that www.domain.com resolves correctly. Currently I have the www pointing to pages.dev but I’ll try changing it so that the www targets to my base/naked domain instead of the pages.dev. I’ll update here tomorrow if that works.
I got it working. Don’t know how I didn’t stumble upon to this post before: Correct DNS for Cloudflare Pages?. So the thing that I had to do in order to get the subdomain working: I had to navigate on Cloudflare pages to ‘Pages’ → choose the project → custom domains → ‘Set up custom domain’ → add the subdomain there. After adding the subdomain, I got notification that the CNAME record is updated and after a while it started working. It wasn’t enough that the DNS record was configured but you have to also add the custom (sub)domain to the project