koa-better-cors
v0.0.3
Published
cors middleware for Koa
Downloads
15
Maintainers
Readme
koa-better-cors
CORS middleware for Koa
Installation
https://npmjs.org/package/koa-better-cors
$ npm install koa-better-cors
Usage
const Koa = require('koa')
const Router = require('koa-router')
const cors = require('koa-better-cors')
const app = new Koa()
const router = new Router()
app.use(cors())
router.get('/', (ctx, next) => {
ctx.body = 'Hello World'
})
app.use(router.routes())
app.listen(10086)
Options
// example
// {
// credentials: true,
// expose: ['Cache-Control','Content-Type'],
// headers: ['Accept','Content-Type'],
// maxAge: 600,
// methods: ['GET','HEAD','PUT','POST','DELETE'],
// origin: 'https://www.love.com',
// }
// defaults
// const defaults = {
// origin: true,
// methods: 'GET,HEAD,PUT,POST,DELETE',
// }