-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Feature Request: Render 404s internally for kit.appDir assets #9802
Comments
Posted in discord before I found this thread. Doing this would be nice for the cloudflare adapter which requires a fallback page for missing assets. The current one is running everyone’s hooks to build the fallback which is annoying for some people #9386 |
I was taking a look at this, and I'm not positive what would be the best way to handle it. Each adapter output is responsible for serving its own We could try to handle this at the adapter level (making it return 404s for missing files under Alternatively, we could bake this into Kit itself, which could presumably happen in a single place, and could affect both Ultimately, it may make sense to handle it in both places - in KIt itself as a fallback, and in any adapters where it is possible to do so. I think the next question is whether any of the adapters already currently work this way. By testing the Svelte and SvelteKit sites, I can see that for the Vercel adapter, missing |
The Cloudflare adapter will always bypass the kit server when making requests to |
Describe the problem
Requests for paths under
/_app/
(or, more generally, under thekit.appDir
folder) that do not match an existing asset are passed along to the user's application. Generally, this just results in a waste of time to generate nice styled error responses that no user will see, but in certain situations can actually result in undesirable behavior.Describe the proposed solution
Requests for all resources under
kit.appDir
should be handled internally by SvelteKit, never reaching the user'shandle
hook, even for missing assets.We'd need to come up with a very generic 404 response for these. There's no real reason for it to be customizable, since this will not be visible to users.
Alternatively, we could render the
src/error.html
template in this case. It doesn't especially matter.Alternatives considered
If people want this optimization, they can also do it in userland, by bailing early in their
handle
hook for/_app/
URLs without callingresolve(event)
.Importance
nice to have
Additional Information
Quoting parts of what I wrote in Discord earlier:
The text was updated successfully, but these errors were encountered: