在egg.js的cofig.default.js中需要配置
security: {
csrf: {
enable: false,
ignoreJSON:true
},
domainWhiteList: ['http://localhost:8080']
},
cors: {
origin: 'http://localhost:8080',
credentials:true,
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
},
在vue中axios中需要添加
axios.defaults.withCredentials = true
来源:oschina
链接:https://my.oschina.net/it110/blog/4523047