合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
[TOC] ### eggjs 跨域配置 文档:https://www.npmjs.com/package/egg-cors * [ ] 安装  npm i egg-cors --save * [ ] 配置插件 ``` // {app_root}/config/plugin.js exports.cors = { enable: true, package: 'egg-cors', }; ``` * [ ] config / config.default.js 目录下配置 ``` config.security = { // 关闭 csrf csrf: { enable: false, }, // 跨域白名单 domainWhiteList: [ 'http://localhost:3000' ], }; // 允许跨域的方法 config.cors = { origin: '*', allowMethods: 'GET, PUT, POST, DELETE, PATCH' }; ```