Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pplgin/koa-http-proxy
https://github.com/pplgin/koa-http-proxy
http-proxy koa-middleware koa2
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pplgin/koa-http-proxy
- Owner: pplgin
- Created: 2017-03-16T04:52:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-21T02:04:40.000Z (almost 6 years ago)
- Last Synced: 2024-03-24T07:01:21.205Z (8 months ago)
- Topics: http-proxy, koa-middleware, koa2
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
## koa-api-proxies
> koa2 http proxy middleware
### Support
post、get、put、delete 基本请求, 文件上传
### Use
```
npm install koa-api-proxies
```### ProxyConfig
| 参数 | 类型 |说明|
|---|---|---|
| target | string | 代理地址(domain+port)|
| path | string(string array)| 代理匹配url,支持字符串数组,字符串 |
| headers | object | 自定义header相关,如`cookie, ua` |
| beforeSend | funciton | 请求前处理,参数ctx, options完整转发配置 |### Example
```javascript
const Koa = require('koa')
const app = new Koa()
const proxy = require('koa-api-proxies')
/**
* use config single
* @type {[type]}
*/
/**
* use config multi
* @type {[type]}
*/
app.use(proxy([{
target: 'http://www.google.com',
path: ['/dist', '/dist2'],
}, {
target: 'http://www.yahoo.com',
path: '/t',
beforeSend:(ctx, options) => {
}
}]))
```