步骤一:
# 下载 egg-cors 包
npm i egg-cors --save
步骤二:
# 在plugin.js中设置开启cors
exports.cors = {
enable: true,
package: 'egg-cors',
};
步骤三:
# 在config.{env}.js中配置,注意配置覆盖的问题
config.cors = {
origin:'*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
};
网友评论