0.1.1 • Published 5 years ago
micro-cors v0.1.1
CORS middleware for Micro
Summary
Simple CORS middleware for Zeit's Micro
Install
yarn add micro-cors
Usage
Basic
const { send } = require('micro')
const cors = require('micro-cors')()
const handler = (req, res) => send(res, 200, 'ok!')
module.exports = cors(handler)
With options
const { send } = require('micro')
const microCors = require('micro-cors')
const cors = microCors({ allowMethods: ['PUT', 'POST'] })
const handler = (req, res) => send(res, 200, 'ok!')
module.exports = cors(handler)
Options
allowMethods
default: ['POST','GET','PUT','PATCH','DELETE','OPTIONS']
allowHeaders
default: ['X-Requested-With','Access-Control-Allow-Origin','X-HTTP-Method-Override','Content-Type','Authorization','Accept']
allowCredentials
default: true
exposeHeaders
default: []
maxAge
default: 86400
origin
default: *
runHandlerOnOptionsRequest
default: false
1.0.0-alpha.2
5 years ago
1.0.0-alpha.1
5 years ago
1.0.0-alpha
5 years ago
1.0.0
5 years ago
0.1.1
6 years ago
0.1.0
6 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago