nitro: Proxy breaks images
Environment
nuxt 3 with nitro 2.4.0, node v18.14.2
Reproduction
https://stackblitz.com/edit/github-xzp2dt?file=nuxt.config.ts,app.vue
(stackblitz doesn’t allow external requests probably, but you get the idea, it still doesn’t work locally)
Describe the bug
When data is json, it works fine
but when data is image, it still return {}
as image
Additional context
example config (used in reproduction):
// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
routeRules: {
'/nuxt/**': {
proxy: {
to: 'https://nuxt.com/**',
},
},
},
});
Logs
the original problem (not reproduction) fails silently, so there’s no log, log below is from stackblitz not being able to proxy requests
[3:16:32 PM] [nuxt] [request error] [unhandled] [500] request to https://nuxt.com/socials/composables.jpg failed, reason: socket hang up (https://nuxt.com/socials/composables.jpg)
at async $fetchRaw2 (file://./node_modules/ofetch/dist/shared/ofetch.502a4799.mjs:197:24)
at async sendProxy (file://./node_modules/h3/dist/index.mjs:607:20)
at async Object.eval [as handler] (file://./node_modules/h3/dist/index.mjs:1348:19)
at async Server.toNodeHandle (file://./node_modules/h3/dist/index.mjs:1423:7)
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 26 (5 by maintainers)
Are you using npm ?
resolutions
is only supported by yarn and pnpm. For npm it’soverrides
.Please consider trying with nitro edge or nuxt edge (it already includes h3 rc. you do not need nightly anymore). And please ping me to reopen if still having issues on edge 🙏🏼
Okay I found out the 304 response is causing the 1 succeed 1 fail with the above modification (because _data becomes empty for 304 responses, obviously, lol)
so changing the modification to the following fixes the problem: