1.0.1 • Published 10 months ago

@waveorb/cors v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
10 months ago

Kross

Cors plugin for NodeJS. Makes it easy to control which domains can access your API from the browser.

Install

npm i @waveorb/cors

Usage

In your web application do this:

var cors = require('@waveorb/cors')

// The default will allow all domains
cors(req, res)

// These are the default options
var options = {

  // If credentials are allowed
  credentials: true,

  // The headers allowed
  headers: [
     'Origin',
     'X-Requested-With',
     'Content-Type',
     'Accept',
     'Authorization',
     'Cache-Control'
  ],

  // The methods allowed
  methods: [
    'GET',
    'POST',
    'OPTIONS',
    'PUT',
    'PATCH',
    'DELETE'
  ],

  // The domain names allowed
  // Undefined (default) means all domains are allowed
  domains: undefined,

  // Specific, multiple supported
  domains: ['https://www.7i.no', 'https://docs.7i.no']
}

// Override them with
cors(req, res, options)

Created by Eldøy Projects

1.0.1

10 months ago

1.0.0

10 months ago