# cors-express2

> Express middleware to enable cross origin resource sharing on a route

Latest version **1.0.0** (published 2019-08-06) · LGPL-3.0 license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-08-06 |
| First published | 2019-08-06 |
| Weekly downloads | 0 |
| License | LGPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michele Tibaldi |
| Maintainers | uwburn |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2019-08-06

## README

# CORS middleware

A simple Express middleware to enable cross origin resource sharing on a route. It will deals with `access-control-allow-origin`, `access-control-allow-credentials`, `access-control-request-headers` and `access-control-allow-methods` headers. `OPTIONS` preflight requests will be directly answered with a `HTTP 200 - OK`.

### Usage

```javascript
var Express = require('express');
var cors = require('cors');

var app = Express();

express.use(cors({
    allowWithoutOrigin: true,
    onlyAllowedOrigin: true,
    allowCredentials: true,
	allowedOrigins: [
		'http://127.0.0.1:8181',
		'http://localhost:8181'
	],
	nullOrigin: 'null'
}));
```

### Options
- `allowWithoutOrigin`: if `true`, allow requests without origin, setting `access-control-allow-origin=*`
- `onlyAllowedOrigin`: if `true`, requires the origin to be in the list of allowed origins
- `allowCredentials`: if `true`, will set `access-control-allow-credentials=true`
- `allowedOrigins`: an array of string representing the allowed origins
- `nullOrigin`: set the string corresponding to `null` origin, most likely the default will always be ok

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