Get assets full URL or trigger handle for fetch(asset)
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
Expose a way in handle to get access to the final deployed path of assets. This will allow things like on the fly image optimisation.
Describe the proposed solution
hooks.server.ts can have a new method handleAssets, or can augment existing method
If you do a fetch('/image.png'), it triggers handleAssets, provides it with the full path to that image. With which I can return a custom response. handleAssets could be used to use sharp on the image on the fly, so inherently making SSR'd image optimisation a reality, like Nuxt Image
Would it be slower than static optimisation? Yes, but sometimes you just cannot optimise early, and the server costs may not matter as much
Alternatives considered
- Do nothing
Importance
would make my life easier
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with hooks.server.ts and trace how fetch('/image.png') is handled for deployed assets. Clarify the API shape for handleAssets, including access to the final asset path and the ability to return a custom response. Done means the behavior and response contract are documented and covered by relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100