eggjs 设置跨域
1.egg-cors
npm install egg-cors --save2.config/plugin.js
exports.cors: {3.config/config.default.js
enable: true,
package: 'egg-cors'
}
config.security = {
csrf: {
enable: false
},
domainWhiteList: [ '*' ]
};
config.cors = {
origin: '*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
};