eggjs 设置跨域

1.egg-cors
npm install  egg-cors --save
2.config/plugin.js
exports.cors: {
enable: true,
package: 'egg-cors'
}
3.config/config.default.js
config.security = {
  csrf: {
    enable: false
  },
  domainWhiteList: [ '*' ]
};

config.cors = {
origin: '*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS'
};

0 个评论

要回复文章请先登录注册