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
fix: Wrap headers with AxiosHeaders to prevent incorrect type being passed #1248
Conversation
hi @danielcooperxyz -- thanks for these changes -- it looks like a build is expected? |
and in the mean time, how are you including this in your |
Did you get any chance at all with this? I'm experiencing the same issue and it would be a shame to have to write my own :( |
const { data, headers, method } = config; | ||
const { data, method } = config; | ||
const headers = new AxiosHeaders(config.headers); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't fix the bug everywhere, you should fix the actual headers when they are set at line 170:
config.headers = signingOptions.headers as AxiosHeaders;
This should not be casted but should be a real AxiosHeaders instance. Otherwise this lib will still break axios for every other uses outside this lib.
If a maintainer could look into this quickly, it would be nice. It's just a oneliner. Here is a workaround in the meantime: axios.interceptors.request.use(async req => {
const signedReq = await interceptor(req);
signedReq.headers = new axios.AxiosHeaders(signedReq.headers);
return signedReq;
}); |
Hey @danielcooperxyz, thanks for putting this fix in. I'll try and get this merged & released today 🤞 |
🎉 This PR is included in version 3.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
We have experienced issues with the latest version of axios (
1.6.3
) passing through bad header objects which are not of the correct type which causes the below error from thetransformRequest
method in axios.This PR includes a new line that will wrap the header object each time regardless of what is passed, to enforce that the correct type is then passed to the transformRequest transformer function.
Fixes #1250