npm install egg-cors --save
npm install egg-bin --save
//config.js
config.security= {
csrf : {
enable: false
},
domainWhiteList: [ 'http://*' ] //这样写才对
}
config.cors = {
// origin: '*', //注释掉,因为不支持cookie
credentials: true, // 允许跨域请求携带cookies
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
}
//plugin.js
cors : {
enable: true,
package: 'egg-cors',
}
网友评论