I have a worker deployed with a very broad/non-specific route, *example.com/*. It handles some generic redirect behavior.
I have other workers with more specific routes, e.g. https://subdomain.example.com/path/*.
This works fine, thanks to Cloudflare Workers' route matching behavior where the most specific routes are matched first.
However, as of wrangler 11.0, I am unable to test my workers with more specific routes. I run wrangler dev and everything starts up fine, but when I make GET requests to http://127.0.0.1/path/anything, those requests are handled by the *example.com/* worker in production.
This is a bug. At the very least, the route matching rules should be applied, using the route/routes in my wrangler.toml file.
This is concerning. It makes me very nervous that my HTTP requests to 127.0.0.1 could be handled by production workers. This implies that if I'm POSTing to localhost with a valid Authorization header, I could be causing side effects in production.
I do not want/expect requests to localhost to be proxied to unrelated deployed production code.
rustc -V: -bash: rustc: command not foundnode -v: v14.8.0npx wrangler -V: 👷 ✨ wrangler 1.11.0wrangler.tomlI think this is related to an issue I'm getting, so I'll comment here to avoid opening a duplicate issue.
Steps to reproduce:
wrangler generate example https://github.com/cloudflare/worker-templatecd in, populate account_id in wrangler.tomlwrangler dev, observe that it workswrangler.toml that includes a wildcard (e.g. route = somesite.com/*)zone_id for that route, and set workers_dev to falsewrangler dev againError: error sending request for url (https://somesite.com/cdn-cgi/workers/preview/?s0=ARPdR5deFqRukgETnkKjn5kSzdo_snRbbMwyeEOIOFMYvs1rH2YrzgvNFKyZQ15Gs6UCiPoylQhuLz_HH692NucZ9_lTDjFeLW5zVueo3fVZQIDl7LgnfW-jQlmD12VveT96NH_KMGy0z6SRtZZmcwy7rWDJs3HaWQqriG6mEyN10p7fyXIsMln87fZM6zKOo-oClrM-iKoq9iCBDVO06NG535432I0gxndTxmWxTY-5NI8MOEgUW5DVur8AGJ-xBSrMoq7JYCKEUHVM2Rww9I3rgOvRWy0PfS4gTEFX7RJv): error trying to connect: dns error: failed to lookup address information: nodename nor servname provided, or not known
This happens whether the route or routes key is specified.
Expected Behavior
I suppose it should look something like this:
I mean basically the expected behavior is what already happens when no route (workers_dev=true) is specified. If I were to speculate, I think the "frontend" for this already works -- workers can already spin up and catch requests to any path on their port, and while I haven't tried it, I suspect the dnsmasq technique works as well. I think it has to do more with the "backend" part, where the worker is actually created based on a route.
@caass for thoroughnesses sake, what is your expected behavior after step 4, and what are you seeing instead of that?
@caass for thoroughnesses sake, what is your expected behavior after step 4, and what are you seeing instead of that?
@TehShrike I edited my comment to put the expected behavior, as well as what actually happens :)
note: status - needs repro indicates that we'd like a member of our team to reproduce; thank you for the detailed report!
Thanks for posting this @TehShrike - I have the same issue as you. I can't test workers that match on subdomains with dev because all requests to localhost are forwarded to the production server for the bare domain.
Most helpful comment
Thanks for posting this @TehShrike - I have the same issue as you. I can't test workers that match on subdomains with dev because all requests to localhost are forwarded to the production server for the bare domain.