koa-undici-proxy
v0.1.0
Published
Yet another Koa proxy based on undici.
Downloads
2
Readme
koa-undici-proxy
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