egg 設(shè)置
1. 下載跨域插件 egg-cors
2. 在plugin.js 配置
exports.cors = {
enable: true,
package: 'egg-cors',
};
3.config.default.js 配置跨域
config.cors = {
origin:'http://localhost:9999', // 跨域設(shè)置cookios 不能設(shè)為 *
credentials: true,
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
};
4. 設(shè)置 ctx.cookies.set('count','aaa');
5. 獲取 ctx.cookies.get('count');
vue 設(shè)置
axios 設(shè)置
const service = axios.create({
withCredentials: true,
crossDomain: true
});