# kcors

> Cross-Origin Resource Sharing(CORS) for koa

Latest version **2.2.2** (published 2018-07-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install kcors
pnpm add kcors
yarn add kcors
bun add kcors
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2018-07-11 |
| First published | 2015-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/kcors) |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 0 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 742 |
| Author | fengmk2 |
| Maintainers | dead_horse, dead-horse, fengmk2 |
| Keywords | cors, koa-cors, Cross-Origin Resource Sharing, @koa/cors, koa, koajs |

## Links

- npm: https://www.npmjs.com/package/kcors
- Repository: https://github.com/koajs/cors
- Issues: https://github.com/koajs/cors/issues
- npm.io page: https://npm.io/package/kcors

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.2.2 (latest) — 2018-07-11
- 2.2.1 (next) — 2017-02-11
- 1.3.3 — 2017-09-13
- 1.3.2 — 2017-02-12
- 1.3.1 — 2016-10-21
- 2.2.0 — 2016-09-26
- 1.3.0 — 2016-09-26
- 2.1.1 — 2016-05-14
- 1.2.1 — 2016-05-14
- 2.1.0 — 2016-04-28
- 1.2.0 — 2016-04-26
- 1.1.0 — 2016-03-06
- 2.0.0 — 2016-02-20
- 1.0.1 — 2015-02-11
- 1.0.0 — 2015-02-09

## README

@koa/cors
=======

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/@koa/cors.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@koa/cors
[travis-image]: https://img.shields.io/travis/koajs/cors.svg?style=flat-square
[travis-url]: https://travis-ci.org/koajs/cors
[codecov-image]: https://codecov.io/github/koajs/cors/coverage.svg?branch=v2.x
[codecov-url]: https://codecov.io/github/koajs/cors?branch=v2.x
[david-image]: https://img.shields.io/david/koajs/cors.svg?style=flat-square
[david-url]: https://david-dm.org/koajs/cors
[download-image]: https://img.shields.io/npm/dm/@koa/cors.svg?style=flat-square
[download-url]: https://npmjs.org/package/@koa/cors

[Cross-Origin Resource Sharing(CORS)](https://developer.mozilla.org/en/docs/Web/HTTP/Access_control_CORS) for koa

## Installation

```bash
$ npm install @koa/cors@2 --save
```

## Quick start

Enable cors with default options:

- origin: request Origin header
- allowMethods: GET,HEAD,PUT,POST,DELETE,PATCH

```js
const Koa = require('koa');
const cors = require('@koa/cors');

const app = new Koa();
app.use(cors());
```

## cors(options)

```js
/**
 * CORS middleware
 *
 * @param {Object} [options]
 *  - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
 *  - {String|Array} allowMethods `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'
 *  - {String|Array} exposeHeaders `Access-Control-Expose-Headers`
 *  - {String|Array} allowHeaders `Access-Control-Allow-Headers`
 *  - {String|Number} maxAge `Access-Control-Max-Age` in seconds
 *  - {Boolean} credentials `Access-Control-Allow-Credentials`
 *  - {Boolean} keepHeadersOnError Add set headers to `err.header` if an error is thrown
 * @return {Function} cors middleware
 * @api public
 */
```

## License

[MIT](./LICENSE)

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