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

Updating xhr adapter to inherit withCredentials flag from the config #1441

Closed
wants to merge 1 commit into from
Closed

Conversation

kmagiera
Copy link

@kmagiera kmagiera commented Mar 28, 2018

This change is necessary to allow updating withCredentials XHR flag in React Native environment where for historical reasons unlike on the web the default value is true.

Link to the web spec: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials

See the default being set to true in React Native here: https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/XMLHttpRequest.js#L133

Prior this change we would only update withCredentials XHR flag if the config was set to true. This was preventing overriding the flag with false in React Native apps. Now we just pass through the config value as long as it is specified. This does not affect the default behaviour on web or React Native as if the flag wasn't set in the config we won't set it on XHR request either.

This also fixes #1101

This change is necessary to allow updating withCredentials XHR flag in React Native environment where for historic reasons unlike on web the default value is `true`.

See the default being set to true here: https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/XMLHttpRequest.js#L133

Prior this change we would only update withCredentials XHR flag if the config was set to true. Now we just pass through the config value as long as it is specified. This does not affect the default behaviour as if the flag wasn't set in the config we won't set it on XHR request either.
@emilyemorehouse
Copy link
Member

Thanks for the PR! Being able to control withCredentials fully is definitely important.

I think we should also add the explicit default for withCredentials set to false in

var defaults = {
so that React Native users don't need to set this themselves.

@kmagiera
Copy link
Author

Changing defaults would introduce a breaking change for everyone using axios on react native. So I believe it is better to keep it the way it is.

@punksta
Copy link

punksta commented May 14, 2018

This is very important pl. Documentation says withCredionals is false by default, but not for react-native.

@racingDeveloper
Copy link

We have the same issue. Even if we set withCredentials: false in react native we get request with "withCredentials": true....

Copy link

@c19354837 c19354837 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've test the code

@chinesedfan
Copy link
Collaborator

Closed in favor of #2582. Apologize for the late response.

@chinesedfan chinesedfan closed this Dec 7, 2019
@axios axios locked and limited conversation to collaborators May 3, 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

Successfully merging this pull request may close these issues.

XMLHttpRequest withCredentials defaults to "true" in ReactNative
6 participants