Skip to content

felidjs/felid-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

felid-cors

npm version Node.js CI JavaScript Style Guide codecov

A Felid plugin for CORS.

Install

npm install felid-cors

or

yarn add felid-cors

Usage

const Felid = require('felid')
const cors = require('felid-cors')

const app = new Felid()
app.plugin(cors, {
  origin: '*',                          // set the `access-control-allow-origin` header, default is the request `Origin` header.
  allowMethods: ['GET,POST'],           // set the `access-control-allow-methods` header, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'.
  exposeHeaders: ['expose', 'headers'], // set the `access-control-expose-headers` header.
  allowHeaders: ['allow', 'headers'],   // set the `access-control-allow-headers` header.
  maxAge: 3600,                         // set the `access-control-max-age` header, in seconds.
  credentials: true                     // set the `access-control-credentials` header.
})

For details, please check corsen.

License

MIT