Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-cors

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-cors - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

52

index.js

@@ -19,4 +19,2 @@ /**

yield next;
var options = {

@@ -48,10 +46,22 @@ origin: settings.origin || defaults.origin,

/**
* Access Control Allow Methods
* Access Control Expose Headers
*/
if (options.methods.join) {
options.methods = options.methods.join(',');
if (options.expose) {
if (options.expose.join) {
options.expose = options.expose.join(',');
}
if (options.expose.length) {
this.set('Access-Control-Expose-Headers', options.expose);
}
}
this.set('Access-Control-Allow-Methods', options.methods);
/**
* Access Control Max Age
*/
options.maxAge = options.maxAge && options.maxAge.toString();
if (options.maxAge && options.maxAge.length) {
this.set('Access-Control-Max-Age', options.maxAge);
}
/**
* Access Control Allow Credentials

@@ -64,2 +74,10 @@ */

/**
* Access Control Allow Methods
*/
if (options.methods.join) {
options.methods = options.methods.join(',');
}
this.set('Access-Control-Allow-Methods', options.methods);
/**
* Access Control Allow Headers

@@ -77,22 +95,2 @@ */

/**
* Access Control Expose Headers
*/
if (options.expose) {
if (options.expose.join) {
options.expose = options.expose.join(',');
}
if (options.expose.length) {
this.set('Access-Control-Expose-Headers', options.expose);
}
}
/**
* Access Control Allow Max Age
*/
options.maxAge = options.maxAge && options.maxAge.toString();
if (options.maxAge && options.maxAge.length) {
this.set('Access-Control-Allow-Max-Age', options.maxAge);
}
/**
* Returns

@@ -102,2 +100,4 @@ */

this.status = 204;
} else {
yield next;
}

@@ -104,0 +104,0 @@

{
"name": "koa-cors",
"version": "0.0.8",
"version": "0.0.9",
"description": "CORS middleware for Koa",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -36,2 +36,11 @@ koa-cors

### expose
Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'WWW-Authenticate,Server-Authorization') or an array (ex: `['WWW-Authenticate', 'Server-Authorization]`). Set this to pass the header, otherwise it is omitted.
### max age
Configures the **Access-Control-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted.
### credentials
Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted.
### methods

@@ -43,11 +52,3 @@ Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`).

### expose
Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'WWW-Authenticate,Server-Authorization') or an array (ex: `['WWW-Authenticate', 'Server-Authorization]`). Set this to pass the header, otherwise it is omitted.
### credentials
Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted.
### maxAge
Configures the **Access-Control-Allow-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted.
For details on the effect of each CORS header, [read this article on HTML5 Rocks](http://www.html5rocks.com/en/tutorials/cors/).

@@ -59,4 +60,2 @@

- Live demo
- More examples
- Enable CORS for a single route

@@ -63,0 +62,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc