local-cors-proxy-bun

A lightweight CORS proxy for local development, powered by Bun


Keywords
cors, proxy, bun, local, development, cors-proxy
License
CC0-1.0
Install
npm install local-cors-proxy-bun@1.0.0

Documentation

local-cors-proxy-bun

npm version

A Bun CORS proxy for local development.

Install

bun add local-cors-proxy-bun

CLI

bunx 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.

Programmatic

import { createProxy } from "local-cors-proxy-bun";

const server = createProxy({ port: 8010, origin: "*", credentials: false });

// server is a Bun.Server instance
server.stop();

Usage

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