cors-expressjs

0.1.2 • Public • Published

cors-expressjs

Cors middleware for Express framework

Build Status Coverage Status

Class based middleware for CORS support for APIs. Based on article HTTP access control (CORS)

Installation

Install Cors as an npm module and save it to your package.json file as a dependency:

npm install --save cors-expressjs

Basic Usage

To start using this middleware you need to create an instance of Cors class. Then you can use middleWare method. Here is example:

    'use strict';
    const express = require('express');
    const Cors = require('cors-expressjs');
    const app = express();
    const cors = new Cors();
 
    app.use(cors.middleWare());
    app.get('/', (req, res) => res.json({ success: true }));
 
    app.listen(3000);

That's it. Very simple :)

Tests

npm test

Package Sidebar

Install

npm i cors-expressjs

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • groupp