@dkx/http-middleware-cors
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

DKX/Http/Middleware/Cors

CORS middleware for @dkx/http-server.

Installation

$ npm install --save @dkx/http-middleware-cors

or with yarn

$ yarn add @dkx/http-middleware-cors

Usage

const {Server} = require('@dkx/http-server');
const {corsMiddleware} = require('@dkx/http-middleware-cors');

const app = new Server;
const corsOptions = {
	domains: ['*']
};

app.use(corsMiddleware(corsOptions));

Options

  • domains:
    • Required
    • Array of allowed domains
    • If there is only one item and it is *, all incoming requests will be allowed
  • methods:
    • Optional
    • Array of allowed methods
    • Sets the access-control-allow-methods HTTP header
  • headers:
    • Optional
    • Array of allowed headers
    • Sets the access-control-allow-headers HTTP header
  • maxAge:
    • Optional
    • Number
    • Sets the access-control-max-age HTTP header
  • credentials:
    • Optional
    • Boolean
    • Sets the access-control-allow-credentials HTTP header

Readme

Keywords

none

Package Sidebar

Install

npm i @dkx/http-middleware-cors

Weekly Downloads

4

Version

0.0.3

License

MIT

Unpacked Size

7.36 kB

Total Files

12

Last publish

Collaborators

  • davidkcz