diff --git a/src/mock/index.js b/src/mock/index.js index e6644ae1..414a2563 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -4,6 +4,15 @@ import articleAPI from './article' import remoteSearchAPI from './remoteSearch' import transactionAPI from './transaction' +// * 修复 Mock 情况下,设置 withCredentials = true,且未被拦截的跨域请求丢失 Cookies 的问题 +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) +} + // Mock.setup({ // timeout: '350-600' // })