Cloudflare worker doesn't work on subdomains but works correctly on root domain

Hi everyone
I’m trying to use Cloudflare as a proxy in front of my netlify site, as I said in my other topic
Now, after resolving the issues with netlify, I have another problem.
My worker gets called without any problem when I set its route to this: mydomain.com/*
But it doesn’t work with this rule: something.mydomain.com/*
What I’m trying to do is to have a worker for every request that is made to my site, including the subdomains.
I’ve also tried *.mydomain.com/* but the worker doesn’t get called at all when I use this rule.

And, my DNS setup is on the proxy and not DNS only (even for something.mydomain.com)

Scratch that (now I’ve gotta go back and fix stuff).

You’d have to have two routes:

  1. example.com
  2. *.example.com

Both running the same Worker.

I’m doing what you said and the first route works correctly, but my worker doesn’t work on something.example.com.
It also doesn’t work when I mention the sub-domain precisely (something.example.com instead of *.example.com)

And that subdomain is set to :orange:? Does the worker check hostname? Does that worker sandbox let you test it on the subdomain?

I just did the two-route setup for domain and wildcard subdomain and it works on my subdomain.

Yeah it was set to proxy on mode.

The problem solved after removing the DNS record for the sub-domain and adding it again (and I think there wasn’t any mistake in the previous record)

Thank you @sdayman for all your help.

1 Like