You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open the devtools console and click the POST REQUEST button to see the issue
You can see how the headers are being turned into a Headers object no matter the original input, making the headers not accesible anymore when the request loops back
$fetchis transforming the headers object into a Headers class if there's a body and the method is other than GET; so if headers are being added in the onRequest interceptor using normal object property accessors instead of the Headers constructor (as shown in the useFetch documentation at the moment I'm writing this issue), when the request is retried and loops back, these are being added as extra properties of the Headers object and ignored later
The expected behavior would be that the headers object was consistent across retried requests, and even across all interceptors
I think the headers object should either be normalized or at least be clear that the Headers constructor is required for modifying the request inside interceptors
Additional context
I came across this issue when I tried to refresh a JWT using the retry option along with the onResponseError interceptor: nuxt/nuxt#26991
I also tried to fix it in this commit, normalizing the headers before the retry and after the onRequest: cmgdragon@8954d8c, though this solution isn't taking into consideration any other interceptor but onRequest for modifying the headers
Logs
No response
The text was updated successfully, but these errors were encountered:
Environment
ofetch 1.3.4
node 20.12.2
Reproduction
https://stackblitz.com/edit/vitejs-vite-53ww8b?file=main.js
Open the devtools console and click the POST REQUEST button to see the issue
You can see how the headers are being turned into a Headers object no matter the original input, making the headers not accesible anymore when the request loops back
Describe the bug
coming from nuxt/nuxt#27042
$fetch
is transforming the headers object into a Headers class if there's a body and the method is other than GET; so if headers are being added in theonRequest
interceptor using normal object property accessors instead of the Headers constructor (as shown in theuseFetch
documentation at the moment I'm writing this issue), when the request is retried and loops back, these are being added as extra properties of the Headers object and ignored laterThe expected behavior would be that the headers object was consistent across retried requests, and even across all interceptors
I think the headers object should either be normalized or at least be clear that the Headers constructor is required for modifying the request inside interceptors
Additional context
I came across this issue when I tried to refresh a JWT using the
retry
option along with theonResponseError
interceptor: nuxt/nuxt#26991I also tried to fix it in this commit, normalizing the headers before the retry and after the onRequest: cmgdragon@8954d8c, though this solution isn't taking into consideration any other interceptor but
onRequest
for modifying the headersLogs
No response
The text was updated successfully, but these errors were encountered: