routeRules never reach the IPX handler: headers are ignored and cache rules silently don't wrap it
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 53/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, node.js, nuxt, typescript
- Ambito
- backend, performance
Direzione di ricerca
Start with the module handler registration in @nuxt/image and Nitro’s route-rule processing; the report says the IPX handler is added after route rules are processed. Check how fromNodeMiddleware(createIPXNodeHandler(...)) handles headers and whether a cached wrapper can be applied. Done means /_ipx/** headers and cache rules work on the self-hosted node preset, with a regression test covering both.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
@nuxt/image2.1.0 (ipx 4.0.0-beta.1), Nuxt 4.5, Nitro node-server preset, self-hosted (Docker behind Traefik)
Describe the bug
routeRules targeting /_ipx/** never affect the IPX handler — neither headers nor cache:
- Headers are ignored.
'/_ipx/**': { headers: { 'cache-control': '…' } }has no effect; the handler writes its own headers via the node middleware and ends the response (fromNodeMiddleware(createIPXNodeHandler(…))). This is probably the root cause behind #992 / #704. cacherules are silently not applied. With'/_ipx/**': { cache: { maxAge: 2592000 } }the built server still registers the handler unwrapped —grep "'/_ipx/\*\*'" .output/server/chunks/nitro/nitro.mjsshows the plain handler entry, nocachedEventHandler, and no cache entries are ever written. The module pushes its handler intonitro.options.handlersafter route-rule processing, so the rule never wraps it.- A scanned server route on the same pattern (
server/routes/_ipx/[...].tswithdefineCachedEventHandler) cannot take over either: both land on the same radix node and the later (module) registration wins.
Why it matters
On self-hosted SSR there is no supported way to put a server-side output cache in front of the IPX transforms. Every variant is re-encoded from the original per first-time visitor; on our vServer that is ~150–450 ms CPU per WebP hero variant (≈0.4–2.8 s for AVIF), per request, as long as no browser cache exists. ipx.fs.maxAge only sets browser cache headers. Related: #795 (SSG cache), #329.
Reproduction
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@nuxt/image'],
nitro: {
routeRules: { '/_ipx/**': { cache: { maxAge: 2592000 } } },
storage: { cache: { driver: 'fs', base: './.cache/nitro' } },
},
})
Build with the node preset, request any /_ipx/... URL twice: identical timings, no cache entries on disk, and the built nitro.mjs lists the /_ipx/** handler without a cache wrapper.
Expected behaviour
Either routeRules (headers and cache) apply to the IPX route like to any other route, or the module offers a documented output-cache option for SSR (e.g. an unstorage-backed transform cache).
Workaround we tried
Renaming the module handler's route to an internal path via a tiny module in nuxt.hook('nitro:init') (also moving runtimeConfig.ipx.baseURL) and serving /_ipx/** from a scanned defineCachedEventHandler proxy route works, but it depends on module internals, so we dropped it. Happy to open a PR if you indicate the preferred direction.
- Lingua principale
- TypeScript
- Stelle
- 1.6k
- Fork
- 335
- Merge medio
- 3g 13h
- PR unite (30g)
- 15
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nuxt/image
-
`<NuxtPicture preload>` ignores `crossorigin` in the preload linkForse già presa @lafllamme l’ha presa 12 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
nuxt/image#2379 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
nuxt/image#2358 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
Bun.Image as an additional, self-hosted provider alongside ipxForse già presa @nathanchase l’ha presa 76 giorni fa. Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug priority: low role: BE stage: now
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
ahmadrosid/nakama#2594 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
milind-soni/OpenMausBot#6495 ·
I maintainer di solito rispondono entro 1 giorno
-
Navigating the session tree adds the branch's prompts to Up-arrow history againForse già presa @acmerfight l’ha presa oggi. Apertauntriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
earendil-works/pi#12279 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
approved documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
vitest-dev/vitest#12015 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno