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

未mock的请求正常发出但没有Cookie导致session无法工作 #402

Open
skyshore2001 opened this issue Feb 9, 2020 · 1 comment

Comments

@skyshore2001
Copy link

skyshore2001 commented Feb 9, 2020

未做mock的请求将发往服务端, 但发现cookie/session没有带上.
是否有选项设置? 还是bug?

version: 1.0.8
node version 12.13.1
windows开发环境.

@skyshore2001
Copy link
Author

跟踪了代码, 出错原理搞清楚了: 由xhr.withCredentials属性设置无效导致

xhr = new XMLHttpRequest();
xhr.withCredentials = true; // 设置到 MockXMLHttpRequest上了, 并没有到真正的内部this.custom.xhr对象上

Mock.setup中未开放相关设置, 我最终是这样来临时解决(绕过)的:

  Mock.XHR.prototype.withCredentials = true

希望能彻底解决此问题, 不用加hack代码,
一个思路是, 在MockXMLHttpRequest(src/mock/xhr/xhr.js)中是否可将withCredentials做成一个属性(带get/set方法的那种)

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

No branches or pull requests

1 participant