@amio/micro-cors
v0.2.0
Published
Simple CORS middleware for Zeit's Micro
Downloads
7
Readme
micro-cors
Simple CORS middleware for Zeit's Micro
Install
npm install @amio/micro-cors
Usage
Basic
const micro = require('micro')
const cors = require('micro-cors')
const handler = (req, res) => micro.send(res, 200, 'ok!')
module.exports = cors()(handler)
With options
const micro = require('micro')
const cors = require('micro-cors')
const options = { allowMethods: 'PUT,POST' }
const handler = (req, res) => micro.send(res, 200, 'ok!')
module.exports = cors(options)(handler)
Options
allowMethods
<String>
default: 'HEAD,GET,POST,PUT,PATCH,DELETE,OPTIONS'
allowHeaders
<String>
default: 'X-Requested-With,Access-Control-Allow-Origin,X-HTTP-Method-Override,Content-Type,Authorization,Accept'
exposeHeaders
<String>
default: undefined
maxAge
<String>
default: 86400
origin
<String>
default: *