New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$fetch
interceptor not modifying the retried request when a body is present
#27042
Comments
Start a new pull request in StackBlitz Codeflow. |
Would you see if you can reproduce this in pure Nitro (reproduction sandbox), and if so, raise there? 🙏 It’s likely an ofetch issue if so. |
I've been able to reproduce it with a simple express server + simple vue app (no Nuxt/Nitro needed).. so It may truly be an ofetch issue. |
No, it's even better if you can report directly to |
I just realized what's going on here. A proposed solution is to normalize the object before hitting the |
Environment
Reproduction
https://stackblitz.com/edit/nuxt-starter-jcgqeq?file=app.vue
Describe the bug
coming from #26991
The
$fetch
interceptor isn't modifying the request headers during aretry
if the request has a body.I'm trying to implement a refresh token functionality using
$fetch
interceptors along with theretry
option. The logic is that when I get a 401 Unauthorized response, the token gets updated and the request is refetched using the new token.It's working just as expected for simple GET requests, but when the same request contains a body, it doesn't update the headers during the retried petition.
I tried to debug inside the
onRequest
interceptor to see if the token was truly being updated, and yes, it was; but the request keeps the old token anyways.The expected behavior would be that the request headers would be modified regardless of whether a body is present
Additional context
In the reproduction link you can see how the uuid isn't being updated in the ssr terminal when the POST includes a body, but it's actually being updated in the onRequest interceptor (open the devtools to see it)
Logs
No response
The text was updated successfully, but these errors were encountered: