Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/robertoachar/express-cors

Express Cross-Origin Resource Sharing (CORS) middleware.
https://github.com/robertoachar/express-cors

cors express middleware node npm

Last synced: about 2 months ago
JSON representation

Express Cross-Origin Resource Sharing (CORS) middleware.

Awesome Lists containing this project

README

        

# express-cors

Generated by [Node Project Generator](https://github.com/robertoachar/generator-node).

[![NPM Version][npm-badge]][npm-url]
[![License][license-badge]][license-url]

> Express Cross-Origin Resource Sharing (CORS) middleware.

This middleware provides the following features:

* **Access-Control-Allow-Origin**: \*
* **Access-Control-Allow-Methods**: GET, POST, PUT, PATCH, DELETE
* **Access-Control-Allow-Headers**: Authorization, Content-Type

# Usage

* Install CORS

```bash
$ npm i @robertoachar/express-cors
```

* Using CORS

```javascript
const express = require('express');
const cors = require('@robertoachar/express-cors');

const app = express();

app.use(cors());

app.get('/', (req, res) => {
res.json({ message: 'It works!' });
});

app.listen(3000, () => {
console.log('Running...');
});
```

# Development

* Cloning the repo

```bash
$ git clone https://github.com/robertoachar/express-cors.git
```

* Installing dependencies

```bash
$ npm install
```

* Running scripts

| Action | Usage |
| ------------ | -------------- |
| Linting code | `npm run lint` |

# Author

[Roberto Achar](https://twitter.com/robertoachar)

# License

[MIT](https://github.com/robertoachar/express-cors/blob/master/LICENSE)

[npm-badge]: https://img.shields.io/npm/v/@robertoachar/express-cors.svg
[npm-url]: https://www.npmjs.com/package/@robertoachar/express-cors
[license-badge]: https://img.shields.io/github/license/robertoachar/express-cors.svg
[license-url]: https://opensource.org/licenses/MIT