# auto-cors

> A proxy to automatically add CORS headers

Latest version **1.0.2** (published 2022-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install auto-cors
pnpm add auto-cors
yarn add auto-cors
bun add auto-cors
```

Provides the command `auto-cors`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-08-14 |
| First published | 2022-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | harttle |
| Maintainers | harttle |

## Links

- npm: https://www.npmjs.com/package/auto-cors
- npm.io page: https://npm.io/package/auto-cors

## Dependencies (3)

- [express](https://npm.io/package/express.md) ^4.18.1
- [request](https://npm.io/package/request.md) ^2.88.2
- [node-fetch](https://npm.io/package/node-fetch.md) ^3.2.5

## Recent versions

- 1.0.2 (latest) — 2022-08-14
- 1.0.1 — 2022-05-25
- 1.0.0 — 2022-05-25

## README

# auto-cors

A proxy to automatically add CORS headers, supports:

- Simple requests with `Access-Control-Allow-Origin: "*"`
- preflight requests for non-simple requests.
- POST/PUT requests with body.
- CORS requests with credentials included.

There's an `auto-cors` service deployed at cors.harttle.com. Both HTTP and HTTPS are supported:

- <http://cors.harttle.com/https://example.com>
- <https://cors.harttle.com/https://example.com>

## `AutoCORS-Cookie` header

Set `Cookie` when forward, `cookie` is not allowed to be set for [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)

```javascript
fetch("https://cors.harttle.com/https://example.com", {
    headers: {
        "AutoCORS-Cookie": "XXX"
    }
})
```

Will set a "Cookie: XXX" header when request is forwarded.

## Deploy your server

Install [node](https://nodejs.org/en/) and `npm`, then run

```bash
npx auto-cors
```

Use `AUTO_CORS_PORT` (defaults to `8080`) to set a different port, for example:

```bash
AUTO_CORS_PORT=8080 npx auto-cors
```

Visit <http://localhost:8080/https://example.com> in your browser.

## Systemd

Here's a systemd script for auto-cors:

<https://gist.github.com/harttle/a801084f42b9ee1a2aa6bf5c191b9ad9>

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