Really confused with Worker Routes

Trying to understand the different ways that you can enter Routes in Cloudflare and getting really confused… Have already read all the Workers documentation and taken Kristian’s excellent Introduction to Cloudflare Workers egghead tutorial, but still not sure.

(Have changed all the names in these following snapshots with Chrome Inspect to protect the innocent. :wink:, but changed them consistently).

In these screenshots:

User: [email protected]
Zone (my website): example.com
Project/Worker: search
Worker.dev subdomain (?): foobar (I can’t remember how this subdomain name got picked or if it matters)

When I log into my dashboard, and just go to my Worker tab right from my User account page, I see this under “Triggers” (yet another new word!):

But when I first navigate to Websites → then pick example.com → Workers, I see this instead:

These routes don’t seem consistent. For a few examples:

  1. search.foobar.workers.dev doesn’t appear under the one for example.com. Why not?
  2. *example.com/favicon.ico (I was running into this issue of every hit serving two requests because it was looking for a favicon, so trying to block that route) doesn’t appear on the routes for [email protected]. Why not?

Lastly, in the wrangler.toml file, there is another way to enter routes, like
route = "*example.com/*"

  1. Is this yet a different way of defining things? I feel like my code is very non-DRY. Does dashboard or .toml file have precedent or override each other?
  2. In the wrangler.toml file, you can only define one route, but so does that conflict with the ability in the dashboard to have certain additional routes excluded, etc.?

I hope you can understand the confusion to someone who hasn’t worked with these workers before. Thanks so much.
Joel

Anybody?

You are in the example.com section and not the global section
Here is routes overview under the Workers section


If I go to cyberjake.xyz zone then I see this

and under cyberjake.cf

My guess as there is no service listed for the route then it won’t show for any worker.

I believe when you publish that the .toml file overwrites your dashboard settings.

You can define multiple routes within the wrangler.toml file. You would use routes = ["route 1", "route 2"]. Route and routes are mutually exclusive so you can only use one in your wrangler.toml` file.

Thank you, Jake, for your reply. That’s very helpful.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.