diff --git a/app.js b/app.js index 4ead8a8..c8902f2 100644 --- a/app.js +++ b/app.js @@ -2,10 +2,16 @@ const config = require('./config') const Koa = require('koa') const koaLogger = require('koa-logger') const koaSession = require('koa-session2') +const cors = require('kcors') const router = require('./route') const app = new Koa() app.use(koaLogger()) +app.use(cors({ + origin: (c) => { + return c.get('Origin') + } +})) app.use(koaSession()) app.use(router.allowedMethods()) app.use(router.routes()) diff --git a/package.json b/package.json index 51b3f70..86d03ab 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dotenv": "^6.0.0", "gm": "^1.23.1", "ioredis": "^3.2.2", + "kcors": "^2.2.2", "koa": "^2.5.1", "koa-body": "^4.0.3", "koa-logger": "^3.2.0",