A Bun CORS proxy for local development.
bun add local-cors-proxy-bunbunx local-cors-proxy-bun --port 8010 --origin "*" --credentials| Flag | Short | Default | Description |
|---|---|---|---|
--port |
-p |
8010 |
Port to listen on |
--origin |
-o |
* |
Access-Control-Allow-Origin value |
--credentials |
-c |
false |
Include Access-Control-Allow-Credentials
|
Environment variables (PORT, ORIGIN, CREDENTIALS) work too — flags take priority.
import { createProxy } from "local-cors-proxy-bun";
const server = createProxy({ port: 8010, origin: "*", credentials: false });
// server is a Bun.Server instance
server.stop();https://localhost:{port}/{encoded URL to proxy}
Prefix any encoded URL with the proxy address.
The proxy strips host, origin, and referer headers, follows redirects, and adds CORS headers to the response.
e.g.
http://localhost:8010/https%3A%2F%2Fapi.example.com%2Fdata