Kxc0822a
2022-04-11 0993108a9566af0e912415f6ef4d37d9e3b65a6d
1
2
3
4
5
6
7
8
9
10
11
12
13
import Mock from 'mockjs'
 
// 修复在使用 MockJS 情况下,设置 withCredentials = true,且未被拦截的跨域请求丢失 Cookies 的问题
// https://github.com/nuysoft/Mock/issues/300
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function() {
  if (this.custom.xhr) {
    this.custom.xhr.withCredentials = this.withCredentials || false
  }
  this.proxy_send(...arguments)
}
 
export default Mock