Workers Assets 404 Behavior
I was wondering if anyone here has played with with workers assets 404 behaviors?
I have a super simple setup with
but it won't serve the 404.html i have in the specified directory in assets and instead throws an exception when a page doesn't exist.
any ideas?
6 Replies
What does your worker look like, are you falling back to the assets binding (
return env.ASSETS.fetch(request)
), if your worker doesn't match anything? Or rather, what's the exception?
Another confusing aspect here is your compat date. If it's greater or equal to April 1st (2025-04-01), there's some new behavior with not found handling. If you're older, then that doesn't apply, and you should follow handing it to the binding
If a Worker is configured and a request does not match a static asset, the Worker will handle the request. The Worker can choose to pass the request to the asset binding (through env.ASSETS.fetch()), following the not_found_handling rules.https://developers.cloudflare.com/workers/static-assets/
yeah the worker in this case is
and the log shows

Error 1101
interesting idea, i have it set to
compatibility_date = "2025-03-28"
hmm, what's your wrangler toml look like? Do you have
binding = "ASSETS"
?, ex:
If you bump it into April, it'll probably just start working because of the new behavior but it's a bit thorny
With April compat date: Requests from browsers, identified by req header sec-fetch-mode: navigate, hit the asset worker instead of the user worker even on misses and invoke not found behavior. If your user worker is just falling back, shouldn't matter for your use case and would even save you some worker invocations, but it can break some setups...that was my issue :facepalm:
didn't have binding= "ASSETS"
ty!