http-proxy-lite

a tiny http proxy of node.js

Usage no npm install needed!

<script type="module">
  import httpProxyLite from 'https://cdn.skypack.dev/http-proxy-lite';
</script>

README

http-proxy-lite

NPM Version Node Version

a tiny http proxy of node.js

Installation

npm i http-proxy-lite -S

Usage

proxy server

import * as http from 'http';
import * as httpProxy from 'http-proxy-lite';

const proxy = httpProxy.createProxyServer();

http
  .createServer(function(req, res) {
    proxy.web(req, res, { target: 'http://127.0.0.1:3001' });
  })
  .listen(3000);

endpoint server

import * as http from 'http';

http
  .createServer(function(req, res) {
    res.end('hello, response from 3001');
  })
  .listen(3001);

then open http://localhost:3000/ with your browser, it will shows hello, response from 3001

Todo

  • xxxx

License

MIT