cors
A strong pick. 4th of 10 web security libraries.
cors is the official Express/Connect middleware that sets CORS headers. It is small and stable, has no known advisories, and is still the standard pick for Express apps. It changes very rarely, ships no built-in types and does not fit Fetch-based frameworks.
Best for: Express or Connect APIs that a browser front end on another origin must call.
Scores
Overall7.6
How strongly do we recommend it for a new project today?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
For Express apps it is the clear default for CORS: safe, tiny, correct and used everywhere. It loses points for very slow development, missing bundled types, an old callback API and a narrow scope tied to Express. Teams on Fastify, Hono or Next.js should use their framework's own CORS support.
- dependents repos: The most used package in the category
- github commitsLastYear: Low activity
- github.com/expressjs/cors/releases: Only release since 2018 is docs and tooling
- npm-compare.com/@fastify/cors,@koa/cors,cors,koa-cors: Alternatives exist per framework
GPT-6.2 Sol: 8.1, likely 7.0 to 9.0
cors is a strong pick for a new Express API that needs browser cross-origin access. It handles the common policies with little setup, and its downstream integrations give confidence in the API. The slow patch cadence and known documentation gaps keep it below the top tier. In the wider category, Helmet covers other security headers and DOMPurify covers HTML sanitization.
- expressjs.com/en/resources/middleware/cors: Documents application-wide preflights and configurable origin policies.
- github.com/expressjs/cors/issues/360: Express 5 users still encounter an outdated preflight example.
- docs.nestjs.com/security/cors: NestJS uses the package under its Express adapter.
- github.commitsLastYear, github.releasesLastYear, peers: Maintenance activity trails several peers that cover complementary security jobs.
Needed by many5.3
How many developers need a tool for this job?
Claude Opus 5.5: 5.5, likely 4.5 to 6.5
Any API that a browser calls from another origin needs CORS, and many backend developers face that. But this package serves only Express/Connect-style Node servers. It also covers one slice of the category's job: headers, not rate limits or HTML sanitizing.
- npm-compare.com/@fastify/cors,@koa/cors,cors,koa-cors: Fastify and Koa each use their own CORS packages
- github description: Node.js CORS middleware for Express/Connect
GPT-6.2 Sol: 5.0, likely 3.8 to 6.2
Cross-origin browser access is common when a frontend and API are hosted separately. Express leads backend framework usage in State of JavaScript 2025, but this package serves Node.js middleware stacks and frameworks such as Fastify and Hono have their own options. The survey measures framework use, so the share of projects that need this package remains uncertain.
- 2025.stateofjs.com/en-US/libraries/back-end-frameworks: Express leads reported backend framework usage.
- expressjs.com/en/resources/middleware/cors: Documents the Express and Connect middleware scope.
- docs.nestjs.com/security/cors: Nest uses a separate CORS implementation on Fastify.
- hono.dev/docs/middleware/builtin/cors: Hono provides built-in CORS middleware.
Helps a lot7.5
How well does it do the job for those who need it?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
It does its narrow job correctly and simply. It has flexible origin matching, per-request options and solid preflight handling, and its docs are now much better. Limits: no built-in types, a callback-only async origin, no Fetch/Request support, and a permissive mode that is easy to misuse.
- github.com/expressjs/cors/releases: 2.8.6 is mostly docs, CI and tooling; no new features
- expressjs.com/en/resources/middleware/cors: Options documented; types come from DefinitelyTyped
- npm hasTypes: No bundled types
- cheatsheetseries.owasp.org/cheatsheets/CORS_Security_Cheat_Sheet.html: Reflecting origin with credentials is a known risk
GPT-6.2 Sol: 8.0, likely 6.8 to 9.0
Version 2.8.6 covers preflights, credentials, and static or dynamic origin policies with a small API. TypeScript needs separate declarations, and the outdated catch-all example is a trap for developers and coding agents using Express 5. Open cache-header reports and limited package-specific performance measurements leave room for uncertainty.
- expressjs.com/en/resources/middleware/cors: Documents preflights, policy callbacks, separate types, and the catch-all example.
- github.com/expressjs/cors/issues/360: A user reports the catch-all example failing on Express 5.
- github.com/expressjs/cors/issues/330: An open report describes a cache-header edge case.
- github.com/expressjs/cors/issues/369: Performance discussion raises questions and leaves them unmeasured.
Holds up over time6.9
Will it still be a good choice in two years?
Claude Opus 5.5: 6.5, likely 5.5 to 7.5
It is feature-complete and sits under the Express technical committee at the OpenJS Foundation, which had renewed security work in 2026. But activity is low: 10 commits and one release in a year, the first release since 2018, and 36 open PRs. The newer frameworks ship their own CORS tools.
- github commitsLastYear: 10 commits, 1 release in the last year
- github openPullRequests: 36 open PRs against 71 merged
- sources.debian.org/src/node-cors/2.8.6-1/HISTORY.md: Gap from 2.8.5 (2018) to 2.8.6 (2026)
- expressjs.com/en/blog: The Express project is active in 2026, with security releases
GPT-6.2 Sol: 7.3, likely 5.9 to 8.6
The January 2026 patch refreshed CI and documentation, had two reviewers, and links to the Express funding collective. The snapshot shows ten commits and one release over the year, well below Helmet and express-rate-limit in commit activity, and several older issues remain open. The established API helps, but the backlog makes the pace of future fixes uncertain.
- github.commitsLastYear, github.releasesLastYear, github.openPullRequests, peers: Ten commits, one release, and 36 open pull requests in the snapshot.
- github.com/expressjs/cors/releases: January patch updated documentation and widened CI coverage.
- github.com/expressjs/cors/pull/390: Two people approved the 2.8.6 release changes.
- github.com/expressjs/cors/blob/v2.8.6/package.json: The package points to the Express Open Collective.
- github.com/expressjs/cors/issues: Several behavior and documentation issues have stayed open for years.
Used widely8.9
How many use it, and is that growing?
Claude Opus 5.5: 9.0, likely 8.0 to 9.5
It has 935k dependent repos, the most in the category by far, and about 500M downloads every 4 weeks. Downloads grew 5.1x in a year, above the 4.1 median. Packages such as engine.io and Apollo Server pull it in, which inflates the downloads, but the dependents count still shows direct use on a huge scale.
- dependents repos: 935,233 repos, against Helmet's 128,887
- npm downloadsLast4Weeks: 498.8M now vs 97.4M a year ago (ratio 5.1)
- engine.io and @apollo/server dependencies: Transitive installs inflate downloads
GPT-6.2 Sol: 8.8, likely 7.7 to 9.8
Ecosyste.ms found 935,233 dependent repositories, over seven times Helmet's count, and 13,273 dependent packages. Four-week downloads rose from 97 million to 499 million, about 5.1× against the catalog median of 4.1×, which suggests a gain in install share. Framework dependencies, repeated CI installs, and sparse recent social discussion make the number of new direct choices harder to pin down.
- dependents.repos, dependents.packages, peers: The observed dependent repository count leads the peer group by a wide margin.
- npm.downloadsLast4Weeks, npm.downloadsSame4WeeksYearAgo, medianDownloadsRatio: Download growth was about 5.1× against a 4.1× median.
- github.com/socketio/socket.io/blob/main/packages/engine.io/package.json: Socket.IO's Engine.IO lists cors as a runtime dependency.
- github.stars, bluesky.posts, hackerNews.stories: 6,197 stars, one recent Bluesky post, and no matched Hacker News stories.
Vouched for7.6
Who stands behind it being good?
Claude Opus 5.5: 7.0, likely 6.0 to 8.0
It is the official Express middleware, recommended in the Express docs, and major projects such as socket.io's engine.io and Apollo Server build on it. No survey covers it. Beyond comparison listings there are few independent write-ups, and it gets little discussion on Hacker News or Bluesky.
- expressjs.com/en/resources/middleware/cors: Listed as official Express middleware
- npm-compare.com/@fastify/cors,@koa/cors,cors,koa-cors: Far ahead of the alternatives in use
- hackerNews stories / bluesky posts: 0 HN stories, 1 Bluesky post (a release note)
- engine.io / Apollo Server: Large projects depend on it
GPT-6.2 Sol: 8.2, likely 7.0 to 9.1
NestJS, Firebase Functions, and Socket.IO each rely on cors for cross-origin handling in their server stacks. Those integrations provide independent evidence that the middleware works in widely used systems. Recent package-specific satisfaction surveys and standalone benchmarks are sparse, which keeps the range wider.
- docs.nestjs.com/security/cors: NestJS delegates CORS on its Express adapter to this package.
- github.com/firebase/firebase-functions/blob/master/src/v2/providers/https.ts: Firebase Functions v2 calls the middleware in its HTTPS handler.
- github.com/socketio/socket.io/blob/main/packages/engine.io/package.json: Engine.IO carries cors as a runtime dependency.
Safe8.3
How safe is it to depend on?
Claude Opus 5.5: 8.5, likely 7.5 to 9.0
There are no advisories in 13 years, only two tiny dependencies (vary, object-assign), and an MIT licence. Releases come from the Express team, which added CodeQL and Scorecard in 2026. The main risk is misconfiguration by users (origin reflection with credentials), not a flaw in the code. The bundle has no Scorecard result to confirm the details.
- advisories total: 0 advisories
- npm dependencies: 2 dependencies
- github.com/expressjs/cors/releases: CodeQL and OSSF Scorecard added
- codeql.github.com/codeql-query-help/javascript/js-cors-misconfiguration-for-credentials: Credential misconfiguration is a known pattern
GPT-6.2 Sol: 8.0, likely 6.7 to 9.2
The MIT-licensed package has two direct runtime dependencies, zero advisories in the OSV snapshot, and a private reporting process through Express. Express's January OpenSSF report scored an earlier commit 7.5 out of 10, and GitHub verifies the 2.8.6 release commit. The current Scorecard and npm publishing permissions remain unverified, and teams must configure allowed origins carefully when enabling credentials.
- advisories.total, npm.dependencies, npm.license, scorecard: Zero OSV advisories, two direct dependencies, MIT, and no current Scorecard in the bundle.
- github.com/expressjs/cors/security/policy: Express provides private vulnerability reporting and security triage.
- github.com/expressjs/security-wg/issues/114: January 2026 Scorecard snapshot gave an earlier commit 7.5 out of 10.
- github.com/expressjs/cors/releases: GitHub marks the 2.8.6 release commit as verified.
- github.com/expressjs/cors/issues/422: An open documentation issue flags permissive origin settings with credentials.
Good
- Covers the usual CORS needs with one call: origin as a string, RegExp, array or function, plus credentials, preflight handling and maxAge.
- No advisories in its history, only two small dependencies, and an MIT licence.
- Maintained under the Express project at the OpenJS Foundation, and so widely used that AI agents and tutorials get it right.
- The 2026 release added CodeQL, Scorecard reporting, current Node CI and much better docs, including per-request config and an FAQ.
Bad
- No bundled TypeScript types; you need @types/cors from DefinitelyTyped.
- The dynamic origin option takes a callback, not a Promise, and the API has not changed since 2018.
- Setting origin: true with credentials: true reflects any origin, which is a common security misconfiguration.
- It only fits Express/Connect-style servers. Fastify, Koa, Hono and Next.js need their own CORS tools.
The numbers
- npm downloads, 4 weeks
- 499M ×5.1 in a year
- GitHub stars
- 6.2k
- Commits, 12 months
- 10
- npm version
- 2.8.6 Jan 2026
- Versions, 12 months
- 1
- Advisories, 24 months
- 0 of 0 ever
- OpenSSF Scorecard
- None
- Licence
- MIT
Read on 21 November 2026 from GitHub (expressjs/cors), npm (cors), OSV and the OpenSSF Scorecard.
Web security libraries
- 8.7DOMPurify
- 8.2Helmet
- 7.9express-rate-limit
- 7.6cors
- 7.4rate-limiter-flexible
- 7.0Upstash Ratelimit
- 6.8sanitize-html
- 6.1csrf-csrf
- 5.7Arcjet
- 5.0js-xss