One Worker for a custom domain, another - a route on the domain

For Workers & Pages, what is the name of the domain?

example.com

What is the issue or error you’re encountering

Cannot achieve the desired routing

What steps have you taken to resolve the issue?

Worker A maps to a custom domain - example.com
Worker B maps to a route - *.example.com/shop

Worker A gets all the traffic, and Worker B cannot get any traffic even when I browse /shop/ route.

A route of *.example.com/shop does not match example.com/shop. It requires a hostname on the front like www.example.com/shop.

If you make the route example.com/shop* then Worker B will get any traffic under the /shop path.

3 Likes

True! Thank you.

I moved one step further now. I’m getting 404 on example.com/shop while shop.account.workers.dev works just fine.

I understand why I’m getting 404. The request does come to Worker B, but it comes with /shop path, and I thought it would come as / path. Not sure if I need to modify the Worker or if there is a way to strip /shop upstream from the Worker B code.

Yes, the path will be the full path, you should just use the full path in the Worker. I don’t know of a good way to make a Worker see a route as its “root” path.

1 Like

I decided to go with example.com and shop.example.com approach since I’m early in the prototyping stage.

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