I use Koa with Node.js 8.1.
Today I found that in my app.js, if I write in this order:
const Koa = require('koa')
var cors = require('koa-cors')
const app = new Koa()
app.use(cors(options))
app.use(router.routes())
the cors can work. I can verify the result via sending origin
header in Postman, and get
Access-Control-Allow-Origin
as response header.
However, if I write in this order:
const Koa = require('koa')
var cors = require('koa-cors')
const app = new Koa()
app.use(router.routes())
app.use(cors(options))
cors will not work correctly.
What's the problem here? AM I missing something?