@koa/cors

WebJar for @koa/cors

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

koa__cors
Last Version

Last Version

2.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

@koa/cors
WebJar for @koa/cors
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/koajs/cors

Download koa__cors

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/koa__cors/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>koa__cors</artifactId>
    <version>2.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/koa__cors/
implementation 'org.webjars.npm:koa__cors:2.2.1'
// https://jarcasting.com/artifacts/org.webjars.npm/koa__cors/
implementation ("org.webjars.npm:koa__cors:2.2.1")
'org.webjars.npm:koa__cors:jar:2.2.1'
<dependency org="org.webjars.npm" name="koa__cors" rev="2.2.1">
  <artifact name="koa__cors" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='koa__cors', version='2.2.1')
)
libraryDependencies += "org.webjars.npm" % "koa__cors" % "2.2.1"
[org.webjars.npm/koa__cors "2.2.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

@koa/cors

NPM version build status Test coverage David deps npm download

Cross-Origin Resource Sharing(CORS) for koa

Installation

$ npm install @koa/cors --save

Quick start

Enable cors with default options:

  • origin: request Origin header
  • allowMethods: GET,HEAD,PUT,POST,DELETE,PATCH
const Koa = require('koa');
const cors = require('@koa/cors');

const app = new Koa();
app.use(cors());

cors(options)

/**
 * CORS middleware
 *
 * @param {Object} [options]
 *  - {String|Function(ctx)} origin `Access-Control-Allow-Origin`, default is request Origin header
 *  - {String|Array} allowMethods `Access-Control-Allow-Methods`, default is 'GET,HEAD,PUT,POST,DELETE,PATCH'
 *  - {String|Array} exposeHeaders `Access-Control-Expose-Headers`
 *  - {String|Array} allowHeaders `Access-Control-Allow-Headers`
 *  - {String|Number} maxAge `Access-Control-Max-Age` in seconds
 *  - {Boolean|Function(ctx)} credentials `Access-Control-Allow-Credentials`, default is false.
 *  - {Boolean} keepHeadersOnError Add set headers to `err.header` if an error is thrown
 * @return {Function} cors middleware
 * @api public
 */

License

MIT

org.webjars.npm

Koa.js

Next generation web framework for Node.js

Versions

Version
2.2.1