Routing not working on root domain
I'm setting up a worker on a brand new cloudflare account. I have tested that it works. I also set up a test subdomain and router for that and found that the worker works properly.
However, when I set up routing for the root domain, the routing doesn't seem to be working. I confirmed that the worker is not getting called in the metrics and logs.
Here is the current setup:
DNS (for example.com) :
*
A @ <ip address>
:cloudflare: (proxy enabled)
* A www <ip address>
:cloudflare: (proxy enabled)
* CNAME test test.com
:cloudflare: (proxy enabled)
Routes:
* *example.com/blog*
-> worker
* example.com/blog*
-> worker
I have tried many different routing patters (such as *example.com/*
and others). I tried deleting the A DNS records and re adding them. I'm really confused about why this isn't routing to my worker. Any help would be greatly appriciated.16 Replies
So you want to route a subdomain to a url with cf rules? Or are you talking about a worker router?
What's the goal?
The goal is to route the root domain through the worker to reverse proxy a blog
I just tested with the subdomain to make sure the worker was working as expected
What's the proxy supposed to do?
Or what's your goal with it?
Aaaaah I think I understand
Its supposed to make it so that if you got to example.com/blog you get content from a wordpress server
You want to apply worker responses only to the /blog path and let everything else be served by the main domain
So you have an IP A with some content and an IP B with your wordpress blog, right?
right
I have run this setup before with other cloudflare accounts too, and its worked fine. But for some reason the routing isn't going into effect for the root domain (example.com)
Can you show us the redirect rule you tried?
Its not a redirect rule, its a worker route

No that should work. 🤔
I have the same issue interestingly when testing.
Have you considered just having one worker that redirects instead of using routes instead?
Could be a workaround
How would that work?
Sth like this:
Or of course by calling the worker itsself.
And I think there should also be a way to get page rules to work for this.
hey @Joe @shellsort , did you manage to get it to work? I have my root domain "example.com" setup to serve a worker. On a specific path "example.com/api/*" I want to serve another worker. I have tried it with trace and even in the logs it shows that my second worker is accessed when /api/ route it hit, but it shows a 404 error based on the first worker. What's going wrong here?
No I never got it to work
nvm looks like the DNS needed to clear up. I got it working now.
Just added this to wrangler.json:
"route": "example.com/api/*",
and waiter for a bit. I guess it was a caching issue. I can access my other worker now.@okHadi (parhlai.com) Did you use a custom domain on the site worker or just a route?
I think it was a custom domain or a route on a custom domain, I'll have to check and confirm haven't touched this in a while