# browser-proxy

> A Proxy For Browser

Latest version **1.0.24** (published 2016-11-07) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install browser-proxy
pnpm add browser-proxy
yarn add browser-proxy
bun add browser-proxy
```

Provides the command `browser-proxy`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.24 |
| Published | 2016-11-07 |
| First published | 2016-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 5.1.1 |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| Author | zobor |
| Maintainers | zobor |
| Keywords | proxy,nodejs proxy, browser-proxy |

## Links

- npm: https://www.npmjs.com/package/browser-proxy
- Repository: http://zobor.me
- Homepage: https://github.com/zobor/browser-proxy
- Issues: https://github.com/zobor/browser-proxy/issues
- npm.io page: https://npm.io/package/browser-proxy

## Dependencies (6)

- [colors](https://npm.io/package/colors.md) ^1.1.2
- [request](https://npm.io/package/request.md) ^2.72.0
- [chokidar](https://npm.io/package/chokidar.md) ^1.5.2
- [deferred](https://npm.io/package/deferred.md) ^0.7.5
- [socket.io](https://npm.io/package/socket.io.md) ^1.4.8
- [node.extend](https://npm.io/package/node.extend.md) ^1.1.5

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.24 (latest) — 2016-11-07

## README

# browser-proxy

## UI界面
![Alt text](./images/pannel.png "UI界面")
![Alt text](./images/resp.png "响应界面")

## 前端调试的代理调试工具
* 代理到本地文件
* 支持host设置（支持单个请求host）
* 代理到url
* 文件合并
* 修改配置立即生效
* 基于nodejs，支持windows, mac, linux
* 添加response headers


## 安装与启动
```
npm install browser-proxy -g

// start browser proxy with default
browser-proxy

// set port & start browser-proxy
browser-proxy -p 8888

// set a config file
browser-proxy -c /path/to/local/file/browser-proxy.config.js
```
## 启动UI界面，浏览器打开

[http://localhost:9000](http://localhost:9000)

## 代理规则

`代理规则参考config.example.js`

### >> 代理请求到本地文件
```
{
	"indexof": "http://m.v.qq.com/tvp/index.html",
	"localFile": "/path/to/local/file/index.html"
}
```
### >> 代理请求到本地目录
```
{
  "regxPath": "http://imgcache.qq.com/tencentvideo_v1/tvp/js/([^?]+)",
  "localPath": "/path/to/local/file/"
}
```
### >> 代理文请求添加responseHeaders
```
{
  "regxPath": "http://imgcache.qq.com/tencentvideo_v1/tvp/js/([^?]+)",
  "localPath": "/Users/zoborzhang/codes/tvp/",
	"responseHeaders": {
		"Access-Control-Allow-Origin":"http://v.qq.com",
		"Access-Control-Allow-Credentials": "true"
	}
}
```
### >> cdn合并请求代理
```
{
  "regxCombo": "http://vm.gtimg.cn/c/=/tencentvideo/txp/js/([^?]+)",
  "replacePath": "\/tencentvideo\/txp\/js\/",
  "localPath": "/path/to/local/file/",
  "responseHeaders": {
	"Access-Control-Allow-Origin":"http://v.qq.com",
	"Content-Type": "application/javascript",
    "Access-Control-Allow-Origin":"*"
  }
}
```
### >> 支持cgi jsonp
```
{
  "indexof": "http://m.v.qq.com/getinfo",
  "localFile": "/path/to/local/file/getinfo.json"
  "useJSONPCallback": true
}
```
### >> cgi指定返回http status code
```
{
  "indexof": "http://m.v.qq.com/getinfo",
  "httpResponseCode": "404"
}
```
### >> 单个请求指定hosts
```
{
  "indexof": "http://qzs.qq.com/tencentvideo_v1/tvp/js/tvp.player_v2_txv_vod.js",
  "host": "10.123.9.9"
}
```
### >> 修改host无需重启app
```
var hosts = function(){
/*

#127.0.0.1 vm.gtimg.cn
127.0.0.1 qzs.qq.com

*/
};
```

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