Deploying a worker at multiple routes

Let’s say I have a zone example.com on Cloudflare with three domains, lorem, ipsum, and dolor. How do I deploy a worker to both lorem.example.com and ipsum.example.com (which can’t be matched by a single pattern other than *.example.com/*), but not dolor.example.com? (Using the pattern *.example.com/* will cause all matching domains, including dolor.example.com, to be routed to the worker.)

Apparently some users can do this in the Workers UI, but not me.

I’ve been looking for ways to deploy the same worker to multiple routes (in the sense of having more than one route patterns). How did you do this?

1 Like

You simply go into the UI and add more routes, selecting the same script as the one running.

1 Like

Hmm… Could you be a bit more specific? I don’t see any option to add/remove routes in the Workers dashboard (https://dash.Cloudflare.com/*/workers/overview) or the editor. What’s in your wrangler.toml file?

I have never used Wrangler to deploy multi-route scripts, I don’t know how multiple routes should be configured there. I guess you could easily configure them via the UI and then don’t overwrite them.

For the UI I should have been slightly more specific, you go into each zone’s Workers page, launching the editor there. You’ll see the routes tab.

That’s strange. I don’t see a “routes” tab on the editor page.

Because you not in the zone’s Workers tab. You are on the Workers overview editor.

Go into a zone/domain and select workers -> open editor.

You can do that with multiple routes.

Is this the page you’re talking about?

Yes. Open the editor.

Oh jeez, missed it right in front of my face!

Thanks a lot!

2 Likes