Open StevenPewsey opened 3 months ago
I too believe this was a bit of breaking change and doesn't work as expected. I'm using nuxt's routeRules
to specify proxies and I don't think there's any way to manually forward headers from there. For API responses, I can probably hard code it:
routeRules: {
'/api/**': {
proxy: {
to: '...',
headers: { accept: 'application/json' }
}
},
But I also have stuff like:
'/images/**': {
proxy: {
to: '...'
}
},
I want the backend to be able to determine what the browser supports. Currently it always responds with the fallback format instead of modern ones like avif even if the browser support them because that info is removed while proxying.
For the time being, creating a middleware for proxying and calling proxyRequest like OP wrote seems to work.
I am facing this issue, too. I am missing the following headers when using routeRules:
"accept": "application/json",
"x-xsrf-token": "...=",
which breaks my auth against Laravel Sanctum, which worked in the past using a routeRules-proxy.
Environment
Node 18.16.1
Reproduction
N/A
Describe the bug
Following https://github.com/unjs/h3/pull/646, proxyRequest ignores any
Accept
headers.This is breaking my application (following a nuxt upgrade from 3.9 -> 3.11) as we proxy api requests via the server to a backend API, which requires us to send through an
Accept
header.As a fix for the timebeing I can explicitly pass through the
Accept
header as followsbut this feels a bit unnecessary to me, I would have expected h3 to send through this header by default.
Additional context
No response
Logs
No response