# @types/cors

> TypeScript definitions for cors

Latest version **2.8.19** (published 2025-06-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/cors
pnpm add @types/cors
yarn add @types/cors
bun add @types/cors
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 2.8.19 |
| Published | 2025-06-07 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51440 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/cors
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors
- npm.io page: https://npm.io/package/@types/cors

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 2.8.19 (latest) — 2025-06-07
- 2.8.17 (ts4.5) — 2023-11-20
- 2.8.14 (ts4.4) — 2023-09-04
- 2.8.13 (ts4.2) — 2022-12-05
- 2.8.12 (ts3.9) — 2021-07-09
- 2.8.10 (ts3.4) — 2021-02-14
- 2.8.9 (ts3.3) — 2020-12-10
- 2.8.8 (ts3.2) — 2020-10-10
- 2.8.7 (ts3.1) — 2020-07-31
- 2.8.6 (ts2.4) — 2019-08-19
- 2.8.5 (ts2.2) — 2019-04-25
- 2.8.1 (ts2.0) — 2017-03-11
- 2.8.18 — 2025-05-08
- 2.8.16 — 2023-11-07
- 2.8.15 — 2023-10-18
- … 19 more at https://npm.io/package/@types/cors/versions

## README

# Installation
> `npm install --save @types/cors`

# Summary
This package contains type definitions for cors (https://github.com/expressjs/cors/).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cors/index.d.ts)
````ts
/// <reference types="node" />

import { IncomingHttpHeaders } from "http";

type StaticOrigin = boolean | string | RegExp | Array<boolean | string | RegExp>;

type CustomOrigin = (
    requestOrigin: string | undefined,
    callback: (err: Error | null, origin?: StaticOrigin) => void,
) => void;

declare namespace e {
    interface CorsRequest {
        method?: string | undefined;
        headers: IncomingHttpHeaders;
    }
    interface CorsOptions {
        /**
         * @default '*'
         */
        origin?: StaticOrigin | CustomOrigin | undefined;
        /**
         * @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
         */
        methods?: string | string[] | undefined;
        allowedHeaders?: string | string[] | undefined;
        exposedHeaders?: string | string[] | undefined;
        credentials?: boolean | undefined;
        maxAge?: number | undefined;
        /**
         * @default false
         */
        preflightContinue?: boolean | undefined;
        /**
         * @default 204
         */
        optionsSuccessStatus?: number | undefined;
    }
    type CorsOptionsDelegate<T extends CorsRequest = CorsRequest> = (
        req: T,
        callback: (err: Error | null, options?: CorsOptions) => void,
    ) => void;
}

declare function e<T extends e.CorsRequest = e.CorsRequest>(
    options?: e.CorsOptions | e.CorsOptionsDelegate<T>,
): (
    req: T,
    res: {
        statusCode?: number | undefined;
        setHeader(key: string, value: string): any;
        end(): any;
    },
    next: (err?: any) => any,
) => void;
export = e;

````

### Additional Details
 * Last updated: Sat, 07 Jun 2025 02:15:25 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Alan Plum](https://github.com/pluma), [Gaurav Sharma](https://github.com/gtpan77), and [Sebastian Beltran](https://github.com/bjohansebas).

---
_Source: https://npm.io/package/@types/cors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
