Wildcard on Workers Routes

Hi Cloudflare Community,

I’m trying to setup my Routes for the Cloudflare Workers.

I tried both *.domain.com/* and *domain.com/* as per Cloudflare’s documentation here

When I tried to

curl -v https://domain.com/

I could see my added HTTP headers, but when I tried to

curl -v https://sub.domain.com/

I could’t see my HTTP headers on both routes mentioned above.

I could only see my HTTP headers if I add additional route which is sub.domain.com/*

Is there something wrong with the wildcard that I’m using?


Try sub.domain.com* if you need a route to sub.domain.com or something like sub.domain.com?something=true

I currently have quite a number of subdomains, which I would like to apply the same Workers to all.

Is there a way to use wildcard, or do I need to specify the routes 1 by 1 per subdomain?

You need to use both *.domain.com* and *.domain.com/* to cover all subdomains and routes.

That’s currently my issue, I have tried *.domain.com/*and *.domain.com*.

The first one *.domain.com/* doesn’t seem to apply the Workers to my sub.domain.com.

The second one is not accepted by Cloudflare, it returned an error msg saying,

Route pattern must include zone name: .domain.com
Use an asterisk (*) character to create dynamic patterns that match multiple URLs. Learn more

Could you kindly advise?

I’ve been experimenting with this as well, it seems that the specific hostname that matches the Worker route needs to be proxied by Cloudflare, and proxied wildcard DNS entries are an enterprise only feature: Cloudflare DNS FAQ – Cloudflare Help Center. Therefore on a free plan, you need a proxied (not DNS-only) name for each individual domain on which you want to run workers.

Some confirmation would be great on this from the Cloudflare folks, and perhaps they should clear up the documentation to communicate that while they will let you set a worker to handle a route like https://*.workers.example.com/*, you can’t actually use it unless you’re on an enterprise plan.