
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
A universal Cross-Origin Resource Sharing(CORS) middleware. Derrived from @koa/cors.
npm install corsen
or
yarn add corsen
Enable cors with default options:
const http = require('http')
const cors = require('corsen')({
// place your options here
})
const server = http.createServer((req, res) => {
cors(req, res)
// if you pass a function to options.origin and that function returns a Promise, you can use async/await: await cors(req, res)
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('ok')
})
/**
* CORS middleware
*
* @param {Object} [options]
* - {String|Function(req, res)} 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} credentials `access-control-allow-credentials`
* @return {Function} cors middleware
* @api public
*/
All the commit before 71c4d00 are credited to koajs contributors.
corsen
has a signature of function(http.IncomingMessage, http.ServerResponse)
, while @koa/cors
recieves a koa's Context
object.corsen
are lowercase.corsen
has removed the error handling utility of @koa/cors
. There is not keepHeadersOnError
porperty in options.felid-cors A Felid plugin for CORS.
FAQs
A universal Cross-Origin Resource Sharing(CORS) middleware
The npm package corsen receives a total of 8 weekly downloads. As such, corsen popularity was classified as not popular.
We found that corsen demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.