/**
* 临时伪造Cookie
* @param cookieInfo cookie对象
*/
npm install js-cookie写法
export const setTempCookie = (cookieInfo="") => {
try {
const subDomain = getDomain();
let tempinfo = cookieInfo.split(';');
tempinfo.forEach(i => {
Cookie.set(i.split('=')[0].trim(), i.split('=')[0].trim() == 'ti-ticket' ? i.split('=')[1] + '=' : i.split('=')[1], { domain: subDomain });
});
} catch (error) {
console.log('伪造cookie出错',error);
}
};
/**
* 临时伪造Cookie 原生写法
* @param cookieInfo cookie对象
*/
export const setTempCookie = (cookieInfo="") => {
try {
const subDomain = getDomain();
let tempinfo = cookieInfo.split(';');
tempinfo.forEach(i => {
document.cookie=i;
});
} catch (error) {
console.log('伪造cookie出错',error);
}
};
把别的域的cookie写在本地或者别的地方,然后走一下webpack代理,就能实现联调了