Skip to content

有个bug,MockXMLHttpRequest中XHR的属性withCredentials始终为false #300

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

Open
DevilishMan opened this issue Jun 16, 2018 · 2 comments

Comments

@DevilishMan
Copy link

DevilishMan commented Jun 16, 2018

这里有一个bug,在send请求的时候没有用外部设置比如用的是axios设置的timeout和withCredentials去覆盖MockXMLHttpRequest中xhr里面的timeout和withCredentials属性,由于MockXMLHttpRequest中的xhr是open的时候创建的原生的XMLHttpRequest对象的实例,后面没有用设置的值去覆盖初始化的属性值,所以导致withCredentials属性在发送请求时始终为false
image

@DevilishMan DevilishMan changed the title 有个bug,MockXMLHttpRequest中的withCredentials始终为false 有个bug,MockXMLHttpRequest中XHR的属性withCredentials始终为false Jun 16, 2018
@ijse
Copy link

ijse commented Oct 3, 2018

这个问题很坑,花了不少时间才找到是mockjs问题,希望尽快修复这个问题

@winzipsdo
Copy link

不知道题主解决问题了没有可以考虑使用以下全局配置

import Mock from 'mockjs';
Mock.XHR.prototype.withCredentials = true;

https://www.jianshu.com/p/fe5f775b541d

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

3 participants