Skip to content
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: axios common headers set #693

Merged

Conversation

mathieu-gilloots
Copy link
Contributor

@mathieu-gilloots mathieu-gilloots commented Oct 14, 2022

Hello,
Upgrading from axios 0.27.2 to 1.1.2 makes requests failed.
Without this PR, vue-auth will add a "common" header to the request as an object.
image

With this PR, we correctly set the header, always by merging the existing ones.
image

Need a release for correcting vue-auth with axios 1.x

Note: I just changed a src/drivers/http/axios.js but the npm run build make some indentation update.

@websanova
Copy link
Owner

websanova commented Oct 15, 2022

This would break backwards compatibility though, no?

Really this should be as a 0.x and 1.x driver with the change, but since the current file is already named 1.x that will mess up anyone who updates.

Not sure if we can just put a if (request.headers.common) check there, I'll need to test this a bit.

@mathieu-gilloots
Copy link
Contributor Author

Hello,
It's what I think, but after read the axios 0.x and 1.x it's seams the common attributes it's only applicable to (instance|axios).defaults.headers not on the request.
I don't know why it's works on the axios 0.x on the request.headers

Axios 0.x doc : https://github.com/axios/axios/tree/v0.x#global-axios-defaults
Axios 1.x doc : https://github.com/axios/axios/tree/v1.x#global-axios-defaults

We could put and if (request.headers.common) but in the 0.x with setHeaders, it's simply add headers specified in common along the existing headers. (there is no common header on the request at execution).

@websanova websanova merged commit 7d075dd into websanova:master Oct 17, 2022
@websanova
Copy link
Owner

Ok, I just tested this in axios 0.21.1 and 1.1.3, seems to work fine in both so went ahead and merged this in, available at version 4.2.0.

Just a note, next time no need to run/push the build, those need to be versioned anyway, so I just do that on my end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants