0.2.0 • Published 2 years ago

kross v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Kross

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

Install

npm i kross

Usage

In your web application do this:

const cors = require('kross')

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

// These are the default options
const 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)

MIT Licensed. Enjoy!

0.1.2

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago