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

It's not possible to set withCredentials false #1837

Closed
fabiopaiva opened this issue Oct 18, 2018 · 5 comments
Closed

It's not possible to set withCredentials false #1837

fabiopaiva opened this issue Oct 18, 2018 · 5 comments

Comments

@fabiopaiva
Copy link

fabiopaiva commented Oct 18, 2018

Summary

I would like to set the property withCredentials as false but it's checking a falsy boolean to set it:

// Add withCredentials to request if needed
    if (config.withCredentials) {
      request.withCredentials = true;
    }

My problem is using React Native, which sets the default value of withCredentials as true. Here

Then, axis will ignore if I set withCredentials false on my request.

I would suggest something like this:

// Add withCredentials to request if needed
    if (typeof config.withCredentials !== 'undefined') {
      request.withCredentials = !!config.withCredentials;
    }
@fabiopaiva
Copy link
Author

@ikhilko
Copy link

ikhilko commented Nov 8, 2018

It's fixed in #1852

@yasuf
Copy link
Collaborator

yasuf commented Dec 9, 2019

sorry if this is sort of an obvious question, did you try setting it to false on the config you send to axios? even if react-native sets it to true as a default, if you change it to false, what's inside the conditional should not be run right? and credentials wouldn't be used in that case, let me know if I'm missing something here!

@yasuf
Copy link
Collaborator

yasuf commented Dec 9, 2019

sorry, I got it, react native sets it to true at the XMLHttpRequest level

@chinesedfan
Copy link
Collaborator

Solved by #2582.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants