# proxyhttp

> node 接口转发中间件（代理）

Latest version **0.0.5** (published 2020-04-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install proxyhttp
pnpm add proxyhttp
yarn add proxyhttp
bun add proxyhttp
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2020-04-10 |
| First published | 2017-08-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | zhangling |
| Maintainers | zhangling |

## Links

- npm: https://www.npmjs.com/package/proxyhttp
- Repository: https://github.com/zhanglingx/proxyhttp
- Homepage: https://github.com/zhanglingx/proxyhttp#readme
- Issues: https://github.com/zhanglingx/proxyhttp/issues
- npm.io page: https://npm.io/package/proxyhttp

## Recent versions

- 0.0.5 (latest) — 2020-04-10
- 0.0.4 — 2017-12-26
- 0.0.3 — 2017-12-22
- 0.0.2 — 2017-08-20
- 0.0.1 — 2017-08-20

## README

# proxyhttp

Node 接口代理中间件

## 安装
```bash
npm install proxyhttp -D
```

## 使用
```js
var app = express()

// parse body for send post data
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

// 简单粗暴的接口转发，配置如下：
app.use("/api", require("proxyhttp")({
    "extranet": "http://ip:port/api"
}))

// 解析：node捕捉到接口标记（baseUrl）`/api`，将`http://a.com/api`转发到`http://ip:port/api`

// 若公司区分内往、外网，通过配置ip自动进行接口转发：
app.use("/api", require("proxyhttp")({
    // 内网对应的公网IP(若不设置，默认外网服务)
    "ip": "112.64.124.86",
    // 内网服务地址
    "intranet": "http://ip:port/api",
    // 外网服务地址
    "extranet": "http://ip:port/api"
}))
// 若公网ip匹配成功（公司内），则转发到内网服务地址（开发环境）
// 若公网ip匹配失败（家里），则转发到外网服务地址（测试环境）
```

## Todo
- [ ] 支持文件上传

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