Skip to content
/ cors Public
forked from koajs/cors

Cross-Origin Resource Sharing(CORS) for koa

License

Notifications You must be signed in to change notification settings

lfreneda/cors

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kcors

NPM version build status Test coverage Gittip David deps npm download

Cross-Origin Resource Sharing(CORS) for koa

Installation

$ npm install kcors --save

Quick start

Enable cors with default options:

  • origin: *
  • allowMethods: GET,HEAD,PUT,POST,DELETE
var koa = require('koa');
var cors = require('kcors');

var app = koa();
koa.use(cors());

cors(options)

/**
 * CORS middleware
 *
 * @param {Object} [options]
 *  - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is '*'
 *  - {String|Array} allowMethods `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE'
 *  - {String|Array} exposeHeaders `Access-Control-Expose-Headers`
 *  - {String|Array} allowHeaders `Access-Control-Allow-Headers`
 *  - {String|Number} maxAge `Access-Control-Max-Age` in seconds
 *  - {Boolean} credentials `Access-Control-Allow-Credentials`
 * @return {Function}
 * @api public
 */

License

MIT

About

Cross-Origin Resource Sharing(CORS) for koa

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%