We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
一个React-Native项目,排查其中某个问题。通过抓包发现请求都带上了cookie从而导致了一个意外的问题。 经排查发现,项目中并没有显示设置axios配置withCredentials:true 而Axios文档中明确说明withCredentials默认为false
React-Native
cookie
withCredentials:true
withCredentials默认为false
问题来了,难道是默认值没有生效?
于是手动设置了withCredentials:false
withCredentials:false
仍然不生效...
进一步猜测会不会是axios到达native层由于某种机制或者限制被篡改了呢?
axios
native
发现了React-Native中的XMLHttpRequest
XMLHttpRequest
withCredentials默认值为true。否定了之前的猜测,只有一步步debug axios源码看看端倪。
axios/lib/adapters/xhr.js#L132
这部分代码问题就很明显了,如果设置了withCredentials:false, 不会走到这部分代码块中,从而导致设置的withCredentials:false会被忽略。
详细描述可以看看这个 PR
记录问题,记录排查问题的过程。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
问题描述
问题定位
问题来了,难道是默认值没有生效?
于是手动设置了
withCredentials:false
仍然不生效...
进一步猜测会不会是
axios
到达native
层由于某种机制或者限制被篡改了呢?发现了
React-Native
中的XMLHttpRequest
withCredentials默认值为true。否定了之前的猜测,只有一步步debug axios源码看看端倪。
axios/lib/adapters/xhr.js#L132
这部分代码问题就很明显了,如果设置了
withCredentials:false
, 不会走到这部分代码块中,从而导致设置的withCredentials:false
会被忽略。解决
详细描述可以看看这个 PR
最后
记录问题,记录排查问题的过程。
The text was updated successfully, but these errors were encountered: