How to natively support wildcard subdomains (*.example.com) on Cloudflare Pages via Workers?
Hey everyone, I could not find a proper answer for this problem so I hope you don't mind I'm asking here.
I’m trying to solve this scenario natively within Cloudflare (no external servers or reverse proxies):
My goal is to:
What I tried:
What I'm looking for:
Is there any native way to automatically map *.example.com to a Worker?
Or make a Worker catch all (leftover) subdomains without manually registering each?
Any other solution I missed?
Thank you guys in advance!
I’m trying to solve this scenario natively within Cloudflare (no external servers or reverse proxies):
- Serve my Cloudflare Pages app under wildcard subdomains, like:
- user1.example.com
- user2.example.com
- Created a Worker to proxy *.example.com to example.com.
Set *.example.com DNS to dummy A record (192.0.2.1) with proxy enabled → Did not trigger worker for custom domain.
Tried to attach route .example.com/ to the Worker → Not allowed.
Tried to add a CNAME for the worker directly for *.example.com → Allowed, but got 522 host error for any custom domain.
Manually added user1.example.com → works fine using worker rerouting, but doesn't scale, so it's not good for me in the long run.
Is there any native way to automatically map *.example.com to a Worker?
Or make a Worker catch all (leftover) subdomains without manually registering each?
Any other solution I missed?
Thank you guys in advance!