# forilan-http-proxy

> http proxy middleware for http

Latest version **1.0.8** (published 2021-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install forilan-http-proxy
pnpm add forilan-http-proxy
yarn add forilan-http-proxy
bun add forilan-http-proxy
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2021-04-28 |
| First published | 2021-02-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 32 |
| Unpacked size | 75.7 KB |
| Known vulnerabilities | 0 (+11 in 6 direct dependencies) |
| Install scripts | no |
| Author | forilan |
| Maintainers | forilan |

## Links

- npm: https://www.npmjs.com/package/forilan-http-proxy
- npm.io page: https://npm.io/package/forilan-http-proxy

## Dependencies (32)

- [qs](https://npm.io/package/qs.md) 6.5.1
- [depd](https://npm.io/package/depd.md) ~1.1.2
- [etag](https://npm.io/package/etag.md) ~1.8.1
- [send](https://npm.io/package/send.md) 0.16.2
- [vary](https://npm.io/package/vary.md) ~1.1.2
- [debug](https://npm.io/package/debug.md) ^3.0.1
- [fresh](https://npm.io/package/fresh.md) 0.5.2
- [cookie](https://npm.io/package/cookie.md) 0.3.1
- [accepts](https://npm.io/package/accepts.md) ~1.3.5
- [methods](https://npm.io/package/methods.md) ~1.1.2
- [type-is](https://npm.io/package/type-is.md) ~1.6.16
- [parseurl](https://npm.io/package/parseurl.md) ~1.3.2
- [raw-body](https://npm.io/package/raw-body.md) ^2.3.0
- [statuses](https://npm.io/package/statuses.md) ~1.4.0
- [encodeurl](https://npm.io/package/encodeurl.md) ~1.0.2
- [proxy-addr](https://npm.io/package/proxy-addr.md) ~2.0.3
- [body-parser](https://npm.io/package/body-parser.md) 1.18.2
- [es6-promise](https://npm.io/package/es6-promise.md) ^4.1.1
- [escape-html](https://npm.io/package/escape-html.md) ~1.0.3
- [on-finished](https://npm.io/package/on-finished.md) ~2.3.0
- [safe-buffer](https://npm.io/package/safe-buffer.md) 5.1.1
- [utils-merge](https://npm.io/package/utils-merge.md) 1.0.1
- [content-type](https://npm.io/package/content-type.md) ~1.0.4
- [finalhandler](https://npm.io/package/finalhandler.md) 1.1.1
- [range-parser](https://npm.io/package/range-parser.md) ~1.2.0
- [serve-static](https://npm.io/package/serve-static.md) 1.13.2
- [array-flatten](https://npm.io/package/array-flatten.md) 1.1.1
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) 0.1.7
- [setprototypeof](https://npm.io/package/setprototypeof.md) 1.1.0
- [cookie-signature](https://npm.io/package/cookie-signature.md) 1.0.6
- [merge-descriptors](https://npm.io/package/merge-descriptors.md) 1.0.1
- [content-disposition](https://npm.io/package/content-disposition.md) 0.5.2

## Recent versions

- 1.0.8 (latest) — 2021-04-28
- 1.0.7 — 2021-03-05
- 1.0.6 — 2021-02-19
- 1.0.5 — 2021-02-18
- 1.0.4 — 2021-02-18
- 1.0.3 — 2021-02-18
- 1.0.2 — 2021-02-18
- 1.0.1 — 2021-02-18
- 1.0.0 — 2021-02-18

## README

基于express和express-http-proxy修改的适用于http模块的代理模块.

http middleware to proxy request to another host and pass response back to original caller.

## Install

```bash
$ npm install forilan-http-proxy --save
```

## Usage
```js
proxy(host, req, res, options);
```

### Example:

```js
var http = require('http')();
var proxy = require('forilan-http-proxy');

httpServer = http.createServer(function (req, res) {
    var host = "www.baidu.com";  
    proxy(host, req, res, {
        proxyErrorHandler: function (err, res, next) {
            console.log("proxyErrorHandler:" + err);
        },
        proxyReqOptDecorator: function (proxyReqOpts, srcReq) {
            console.log("proxyReqOptDecorator");
            return proxyReqOpts;
        },

        proxyReqBodyDecorator: function (bodyContent, srcReq) {
            console.log("proxyReqBodyDecorator");
            return bodyContent;
        },
        proxyReqPathResolver: function (req) {
            console.log("proxyReqPathResolver");
            return req.url;
        },
        userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
            console.log("userResHeaderDecorator");
            return headers;
        },
        userResDecorator: function (proxyRes, proxyResData, userReq, userRes) {
            console.log("userResDecorator");
            return proxyResData;
        }
    });
}).listen(80);
```



## Licence

MIT
<!-- do not want to make nodeinit to complicated, you can edit this whenever you want. -->

---
_Source: https://npm.io/package/forilan-http-proxy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
