koa2跨域 发表于 2018-06-09 | 分类于 node | | 本文总阅读量 次 字数统计: 56 | 阅读时长 ≈ 1 “koa2-cors”: “^2.0.5”, 123456789101112131415const cors = require('koa2-cors');app.use(cors({ origin: function(ctx) { if (ctx.url === '/test') { return false; } return '*'; }, exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'], maxAge: 5, credentials: true, allowMethods: ['GET', 'POST', 'DELETE'], allowHeaders: ['Content-Type', 'Authorization', 'Accept'],}));