sveltejs / sveltejs/kit

Hooking into asset serving to avoid 404

Open
#12,815 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

From what I know it's not possible to hook into the serving of build artifacts in the _app folder. The biggest use case I have for it is to be able to hook into it to prevent 404s on assets that no longer exists which is an issue during deployment where clients are still on the "old" version in their browser.

Another use case is being able to have middlewares for the build artifact files to set custom headers, but that's a lot less important.

Describe the proposed solution

Some way of registering a 404 handler for the _app folder or some sort of middleware where I would be able to detect a 404 and prevent it from really becoming a 404.

Alternatives considered

I'm not aware of a way to solve this except perhaps building my own Sveltekit adapter which feels overkill for this.

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how SvelteKit serves build artifacts in the _app folder and how adapters handle missing assets. Compare the requested 404 hook or middleware with the existing serving and deployment behavior. Done should include a supported way to intercept missing _app assets and, if pursued, apply custom headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.