Really confusing 404 handling on static asset serving
My understanding is that
- If the file is in a static asset, serve the asset first (no workers)
- If it's a file not in static assets,
- if the fetch mode is navigate, serve 404.html.
- otherwise run worker
This is very confusing, there may be crawlers that don't respect the navigate fetch mode.
Instead of using workers on routes except for specific assets, it should be create a special route (eg /api) for workers on the entire webpage.
4 Replies
and somehow browser extension would invoke without navigated fetch mode
^ crawlers may request spam it for finding vulnerability such like phpmyadmin htaccess etc
it's def confusing yea, we talked with the team about it and they have something they're working on to essentially bring back Page's _routes.json to a degree https://github.com/cloudflare/workers-sdk/discussions/9143#discussioncomment-13286695
GitHub
Proposal: Support for _routes.json in Workers with static assets ·...
Hi 👋 I’m a product manager on the Workers team, and we’d like feedback on the following proposal for adding support for _routes.json configuration files when using Workers with static assets. In a ...
technically with the sec fetch mode, you're expected to pass the request back to the assets binding
return env.ASSETS.fetch(request);
At the end of your worker code, if it 404s/doesn't hit any specific path
That way even crawlers and stuff w/o it still get the 404 behaviorgotcha, they may would write some notes on documentation for future reference