1.安裝模塊javascript
npm install koa2-cors --save
2.引用java
const cors = require('koa2-cors'); ... // 容許跨域訪問 app.use(cors({ exposeHeaders: ['WWW-Authenticate', 'Server-Authorization', 'Date'], maxAge: 100, credentials: true, allowMethods: ['GET', 'POST', 'OPTIONS'], allowHeaders: ['Content-Type', 'Authorization', 'Accept', 'X-Custom-Header', 'anonymous'], }));
.npm