# cors: 7.6 out of 10

A strong pick. 4th of 10 in [Web security libraries](https://elestia.ai/opensource/web-security/index.md).

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

- **Overall: 7.6** (likely 6.5 to 8.5)
  - Claude Opus 5.5 (7.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.
  - GPT-6.2 Sol (8.1): 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.
- **Needed by many: 5.3** (likely 4.2 to 6.4)
  - Claude Opus 5.5 (5.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.
  - GPT-6.2 Sol (5.0): 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.
- **Helps a lot: 7.5** (likely 6.4 to 8.5)
  - Claude Opus 5.5 (7.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.
  - GPT-6.2 Sol (8.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.
- **Holds up over time: 6.9** (likely 5.7 to 8.1)
  - Claude Opus 5.5 (6.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.
  - GPT-6.2 Sol (7.3): 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.
- **Used widely: 8.9** (likely 7.9 to 9.7)
  - Claude Opus 5.5 (9.0): 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.
  - GPT-6.2 Sol (8.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.
- **Vouched for: 7.6** (likely 6.5 to 8.6)
  - Claude Opus 5.5 (7.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.
  - GPT-6.2 Sol (8.2): 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.
- **Safe: 8.3** (likely 7.1 to 9.1)
  - Claude Opus 5.5 (8.5): 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.
  - GPT-6.2 Sol (8.0): 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.

## 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

- Downloads, 4 weeks: 499M
- In a year: ×5.1
- GitHub stars: 6.2k
- Commits, 12 months: 10
- Last npm release: Jan 2026
- Advisories, 24 months: 0
- Licence: MIT
- GitHub: https://github.com/expressjs/cors
- npm: https://www.npmjs.com/package/cors

Scores run from 0 to 10 and are the mean of the scores of AI reviewers (Claude Opus 5.5, GPT-6.2 Sol), made on 22 November 2026 from GitHub, npm, OSV, OpenSSF Scorecard, ecosyste.ms, Hacker News and Bluesky data and a web search. The ecosyste.ms count of repositories that use a project is far too low for projects that grew in the last few years, and some reviews quote it. Overall is the reviewers' own judgement for a new project today, not an average of the parts. An AI wrote them and can be wrong.
