https://github.com/unjs/httpxy
🔀 A Full-Featured HTTP and WebSocket Proxy for Node.js
https://github.com/unjs/httpxy
Last synced: 15 days ago
JSON representation
🔀 A Full-Featured HTTP and WebSocket Proxy for Node.js
- Host: GitHub
- URL: https://github.com/unjs/httpxy
- Owner: unjs
- License: other
- Created: 2023-08-21T15:53:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T02:10:00.000Z (over 1 year ago)
- Last Synced: 2023-12-28T23:47:09.480Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 174 KB
- Stars: 136
- Watchers: 3
- Forks: 5
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 🔀 httpxy
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![Codecov][codecov-src]][codecov-href]A Full-Featured HTTP and WebSocket Proxy for Node.js forked from [http-party/node-http-proxy](https://github.com/http-party/node-http-proxy) with modern Typescript rewrite.
## Usage
Install package:
```sh
# npm
npm install httpxy# yarn
yarn add httpxy# pnpm
pnpm install httpxy
```Create proxy:
```ts
import { createServer } from "node:http";import { createProxyServer } from "httpxy";
const proxy = createProxyServer({});
const server = createServer(async (req, res) => {
try {
await proxy.web(req, res, {
target: address /* address of your proxy server here */,
});
} catch (error) {
console.error(error);
res.statusCode = 500;
res.end("Proxy error: " + error.toString());
}
});server.listen(3000, () => {
console.log("Proxy is listening on http://localhost:3000");
});
```Checkout [http-party/node-http-proxy](https://github.com/http-party/node-http-proxy) for more options and examples (note: `followRedirects` is not supported).
## Development
- Clone this repository
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`## License
Made with 💛
Published under [MIT License](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/httpxy?style=flat&colorA=18181B&colorB=F0DB4F
[npm-version-href]: https://npmjs.com/package/httpxy
[npm-downloads-src]: https://img.shields.io/npm/dm/httpxy?style=flat&colorA=18181B&colorB=F0DB4F
[npm-downloads-href]: https://npmjs.com/package/httpxy
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/httpxy/main?style=flat&colorA=18181B&colorB=F0DB4F
[codecov-href]: https://codecov.io/gh/unjs/httpxy
[bundle-src]: https://img.shields.io/bundlephobia/minzip/httpxy?style=flat&colorA=18181B&colorB=F0DB4F
[bundle-href]: https://bundlephobia.com/result?p=httpxy