-
Notifications
You must be signed in to change notification settings - Fork 684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: SPA should 404 on fetching obvious non-html assets #257
Comments
In a SPA your 404 is usually being rendered client side, that means you need to first get your |
@sergiodxa the whole point here is that the server isn't returning a 404 -- it's returning |
Thank you for the effort you've put into this! This is now possible by supplying a Simply add |
Sorry to bother but I just stumbled upon this issue recently, and after checked serve-handler documentation I still don't understand how to config it to return 404 status instead of the HTML file. Any help would be greatly appreciated. |
For SPAs, a common issue I've run into is that as hashed static resources change between deployments, a stale client requests an old asset (oftentimes due to a client-side service worker), and failing to find the static resource,
serve
naively returnsindex.html
which is almost never what you want and leads to weird client-side errors.See here and here for solid descriptions of the general problem aside from
serve
.I realize this is how most static file serving solutions work, but I know we can do better for the majority use case, where the requested resource is in a blacklist of common content-types (e.g.,
js
,css
,png
,jpg
,svg
, etc).I'd like to propose adding an optional flag to augment SPA mode whereby these types of resource requests return 404 if not found, instead of naively returning
index.html
.Thoughts?
The text was updated successfully, but these errors were encountered: