0.1.2 • Published 7 years ago

cors-expressjs v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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