Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

SyaOS/koa-undici-proxy

Repository files navigation

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

About

Yet another koa proxy based on undici.

Resources

License

Stars

Watchers

Forks

Packages

No packages published