# micro-cors

> Simple CORS middleware for Zeit's Micro

Latest version **0.1.1** (published 2018-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install micro-cors
pnpm add micro-cors
yarn add micro-cors
bun add micro-cors
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2018-10-05 |
| First published | 2017-01-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/micro-cors) |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 197 |
| Author | Mike Bannister |
| Maintainers | possibilities |

## Links

- npm: https://www.npmjs.com/package/micro-cors
- Repository: https://github.com/possibilities/micro-cors
- Homepage: https://github.com/possibilities/micro-cors#readme
- Issues: https://github.com/possibilities/micro-cors/issues
- npm.io page: https://npm.io/package/micro-cors

## Recent versions

- 0.1.1 (latest) — 2018-10-05
- 1.0.0-alpha.2 (next) — 2019-05-28
- 1.0.0-alpha.1 — 2018-12-25
- 0.1.0 — 2018-01-08
- 0.0.4 — 2017-04-05
- 0.0.3 — 2017-04-04
- 0.0.2 — 2017-04-03
- 0.0.1 — 2017-01-14

## README

# CORS middleware for Micro

### Summary

Simple [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) middleware for Zeit's [Micro](https://github.com/zeit/micro)

[![CircleCI](https://circleci.com/gh/possibilities/micro-cors.svg?style=svg)](https://circleci.com/gh/possibilities/micro-cors)

### Install

```
yarn add micro-cors
```

### Usage

Basic

```js
const cors = require('micro-cors')()
const handler = (req, res) => send(res, 200, 'ok!')

module.exports = cors(handler)
```

With options

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

---
_Source: https://npm.io/package/micro-cors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
