@amio/micro-cors

Simple CORS middleware for Zeit's Micro

Stats

StarsIssuesVersionUpdatedCreatedSize
@amio/micro-cors
010.2.03 years ago4 years agoMinified + gzip package size for @amio/micro-cors in KB

Readme

micro-cors

Build Status

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: *

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.