标签:前端 添加 head npm 开发接口 接口 配置 使用 pos
npm i egg-cors --save // 或 yarn add egg-cors
// 在config/plugin.js里面添加
exports.cors = {
enable: true,
package: ‘egg-cors‘,
};
// 或者,在config/plugin.js的module.exports里面添加
module.exports = {
cors: {
enable: true,
package: ‘egg-cors‘,
}
};
// 在config/config.default.js的module.exports里面添加
config.cors = {
origin: ‘*‘, // 表示允许的源
allowMethods: ‘GET,HEAD,PUT,POST,DELETE,PATCH‘ // 表示允许的http请求方式
};
.
标签:前端 添加 head npm 开发接口 接口 配置 使用 pos
原文地址:https://www.cnblogs.com/crazycode2/p/12445924.html