#How to exclude specific subdomains (like api and id) from triggering a Worker?

8 messages · Page 1 of 1 (latest)

crisp wind
#

Hi everyone,

I’m trying to configure my Cloudflare Worker so that it runs on all subdomains of my domain (*.mydomain.com) except for a couple of specific subdomains — namely apimydomain.com and id.mydomain.com. For these two subdomains, I want the Worker not to be invoked at all.

I’ve tried:

Using route patterns in wrangler.toml/wrangler.jsonc with empty script fields for those subdomains, but I get errors.

Using _routes.json with exclude patterns, but it doesn’t seem to prevent invocation.

Listing all allowed subdomains explicitly — but this is difficult because there are many dynamic subdomains.

Does Cloudflare Workers routing support excluding subdomains from a wildcard route? If not, what’s the best practice to achieve this? Should I handle this logic inside the Worker code itself by checking the hostname and skipping processing?

Thanks in advance for your help!

hidden jackal
#

go do mydomain.com on cloudlfare > routes and then create routes for the subdomains there and set worker to None

lost cave
#

?crossposting -> #1379082992126918697 message

signal pilotBOT
#

Please do not post your question in multiple channels/post it multiple times per the rules at #😃welcome-and-rules. It creates confusion for people trying to help you and doesn't get your issue or question solved any faster.

hidden jackal
crisp wind
crisp wind
hidden jackal