cloudflare-docs icon indicating copy to clipboard operation
cloudflare-docs copied to clipboard

Explain the most specific Workers route

Open Albertozhao opened this issue 4 years ago • 1 comments

Expected Behavior

Users expect setting routes to be intuitive. In the docs, we say wildcards in the subdomain and in the subdirectory will match all requests *.example.com/*, but then we write that adding a wildcard in a route will match everything after the suffix example.com* and run the Worker - even if there's another route added with a trailing slash example.com/*. We also don't explain how routing executes if there's a wildcard on a subdomain.

Actual Behavior

For adding a wildcard on a subdomain, a user asked which route *.example.com/a or a.example.com/* would match a.example.com/a?

From testing, a.example.com/a will match a.example.com/* instead of *.example.com/a (so this needs to be explained).

Section that requires update

Explain how to write the most specific Workers route and add more examples. https://developers.cloudflare.com/workers/platform/routes#matching-behavior

Albertozhao avatar Dec 08 '21 01:12 Albertozhao

I believe we covered this here: https://developers.cloudflare.com/workers/platform/known-issues#route-specificity but may not be what you'd like to address?

deadlypants1973 avatar Dec 13 '21 15:12 deadlypants1973