add cors setting
This commit is contained in:
parent
26b4b077a9
commit
3a07dfbacf
6
app.js
6
app.js
@ -2,10 +2,16 @@ const config = require('./config')
|
|||||||
const Koa = require('koa')
|
const Koa = require('koa')
|
||||||
const koaLogger = require('koa-logger')
|
const koaLogger = require('koa-logger')
|
||||||
const koaSession = require('koa-session2')
|
const koaSession = require('koa-session2')
|
||||||
|
const cors = require('kcors')
|
||||||
const router = require('./route')
|
const router = require('./route')
|
||||||
const app = new Koa()
|
const app = new Koa()
|
||||||
|
|
||||||
app.use(koaLogger())
|
app.use(koaLogger())
|
||||||
|
app.use(cors({
|
||||||
|
origin: (c) => {
|
||||||
|
return c.get('Origin')
|
||||||
|
}
|
||||||
|
}))
|
||||||
app.use(koaSession())
|
app.use(koaSession())
|
||||||
app.use(router.allowedMethods())
|
app.use(router.allowedMethods())
|
||||||
app.use(router.routes())
|
app.use(router.routes())
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"dotenv": "^6.0.0",
|
"dotenv": "^6.0.0",
|
||||||
"gm": "^1.23.1",
|
"gm": "^1.23.1",
|
||||||
"ioredis": "^3.2.2",
|
"ioredis": "^3.2.2",
|
||||||
|
"kcors": "^2.2.2",
|
||||||
"koa": "^2.5.1",
|
"koa": "^2.5.1",
|
||||||
"koa-body": "^4.0.3",
|
"koa-body": "^4.0.3",
|
||||||
"koa-logger": "^3.2.0",
|
"koa-logger": "^3.2.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user