Comparing version 4.0.0 to 4.1.0
25
index.js
@@ -23,2 +23,10 @@ import kcors from '@koa/cors' | ||
description: 'Adds `Access-Control-Allow-Credentials` header.' | ||
}, | ||
{ | ||
name: 'cors.opener-policy', | ||
description: 'A value for the `Cross-Origin-Opener-Policy` header (specify `unsafe-none`, same-origin-allow-popups` or `same-origin`).' | ||
}, | ||
{ | ||
name: 'cors.embedder-policy', | ||
description: 'A value for the `Cross-Origin-Embedder-Policy` header (specify `unsafe-none` or `require-corp`).' | ||
} | ||
@@ -33,4 +41,19 @@ ] | ||
if (config.corsCredentials) corsOptions.credentials = config.corsCredentials | ||
if (config.corsOpenerPolicy) corsOptions.openerPolicy = config.corsOpenerPolicy | ||
if (config.corsEmbedderPolicy) corsOptions.embedderPolicy = config.corsEmbedderPolicy | ||
this.emit('verbose', 'middleware.cors.config', corsOptions) | ||
return kcors(corsOptions) | ||
const koaCorsMiddleware = kcors(corsOptions) | ||
return async function (ctx, next) { | ||
await koaCorsMiddleware(ctx, next) | ||
if (ctx.response.get('Access-Control-Allow-Origin')) { | ||
if (config.corsOpenerPolicy) { | ||
ctx.response.set('Cross-Origin-Opener-Policy', config.corsOpenerPolicy) | ||
} | ||
if (config.corsEmbedderPolicy) { | ||
ctx.response.set('Cross-Origin-Embedder-Policy', config.corsEmbedderPolicy) | ||
} | ||
} | ||
} | ||
} | ||
@@ -37,0 +60,0 @@ } |
{ | ||
"name": "lws-cors", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Support for setting Cross-Origin Resource Sharing (CORS) headers to lws", | ||
@@ -22,7 +22,7 @@ "repository": "https://github.com/lwsjs/cors.git", | ||
"dependencies": { | ||
"@koa/cors": "^3.1.0" | ||
"@koa/cors": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"lws": "^4.1.1", | ||
"node-fetch": "^3.2.0", | ||
"node-fetch": "^3.2.3", | ||
"test-runner": "^0.10.1" | ||
@@ -29,0 +29,0 @@ }, |
@@ -19,2 +19,6 @@ [![view on npm](https://badgen.net/npm/v/lws-cors)](https://www.npmjs.org/package/lws-cors) | ||
--cors.credentials Adds `Access-Control-Allow-Credentials` header. | ||
--cors.opener-policy string A value for the `Cross-Origin-Opener-Policy` header (specify `unsafe-none`, | ||
same-origin-allow-popups` or `same-origin`). | ||
--cors.embedder-policy string A value for the `Cross-Origin-Embedder-Policy` header (specify `unsafe-none` | ||
or `require-corp`). | ||
``` | ||
@@ -21,0 +25,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5639
54
28
Updated@koa/cors@^3.2.0