出现了跨域或Get,Post请求被禁止的情况,需要进行配置,以Koa2为例: const cors = require('koa2-cors') app.use(cors({ origin: function (ctx) { return '*'; //这样就能只允许 http://localhost:8080 这个域名的请求了 }, exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'], maxAge: 5, credentials: true, allowMethods: ['GET', 'POST', 'DELETE'], allowHeaders: ['Content-Type', 'Authorization', 'Accept'], }))
出现了跨域或Get,Post请求被禁止的情况,需要进行配置,以Koa2为例: