egg跨域设置
步骤一:
# 下载 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'
};
推荐阅读
- 第6.2章(设置属性)
- 15、IDEA学习系列之其他设置(生成javadoc、缓存和索引的清理等)
- performSelectorOnMainThread:withObject:waitUntilDone:参数设置为NO或YES的区别
- spring|spring boot中设置异步请求默认使用的线程池
- Python绘制小红花
- day|day 28 设置路由表
- flutter设置沉浸式状态栏
- 谷歌/火狐/Safari浏览器设置手机模式浏览
- vue-cli3.0使用proxytable解决跨域问题
- 自定义dialog在xml设置宽高失效的解决