mish
CDCloudflare Developers
•Created by mish on 4/13/2025 in #general-help
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:
- Serve my Cloudflare Pages app under wildcard subdomains, like:
- user1.example.com
- user2.example.com
Ideally: no need to manually add each subdomain in the Cloudflare dashboard.
➡️ What I tried:
- 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.
➡️ 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!
4 replies