koa-undici-proxy
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

koa-undici-proxy

Node.js CI

Yet another Koa proxy based on undici.

Install

npm install koa-undici-proxy

or

yarn add koa-undici-proxy

Usage

const Koa = require('koa');
const proxy = require('koa-undici-proxy');

const app = new Koa()
app.use(proxy('https://httpbin.org'))

app.listen(3000)

// Now you can access https://httpbin.org/ using http://localhost:3000/

Config

The proxy() function also accepts an undici Client, so you can use it like:

const Koa = require('koa');
const proxy = require('koa-undici-proxy');
const { Client } = require('undici');

const app = new Koa()
const client = new Client('https://httpbin.org', {
  // I want to proxy big blobs so disable the timeout of receiving body.
  bodyTimeout: 0,
})
app.use(proxy(client))

app.listen(3000)

License

MIT License

Readme

Keywords

Package Sidebar

Install

npm i koa-undici-proxy

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

5.33 kB

Total Files

7

Last publish

Collaborators

  • gerhut