micro-cors
Simple CORS middleware for Zeit's Micro
Last updated 2 years ago by tim-phillips .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install micro-cors 
SYNC missed versions from official npm registry.

CORS middleware for Micro

Summary

Simple CORS middleware for Zeit's Micro

CircleCI

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

Current Tags

  • 0.1.1                                ...           latest (2 years ago)
  • 1.0.0-alpha.2                                ...           next (a year ago)

8 Versions

  • 1.0.0-alpha.2                                ...           a year ago
  • 1.0.0-alpha.1                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Downloads
Today 6
This Week 17
This Month 10
Last Day 4
Last Week 10
Last Month 26
Dependencies (0)
None
Dev Dependencies (13)
Dependents (79)

Copyright 2014 - 2016 © taobao.org |