# koa-server-http-proxy

> A koa2 http-proxy-middleware.

Latest version **0.1.0** (published 2018-08-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install koa-server-http-proxy
pnpm add koa-server-http-proxy
yarn add koa-server-http-proxy
bun add koa-server-http-proxy
```

## 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.1.0 |
| Published | 2018-08-06 |
| First published | 2018-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 34.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 38 |
| Author | wqzhang |
| Maintainers | eugene_cn |
| Keywords | koa, koa-proxy, koa-http-proxy, koa-http-proxy-middleware |

## Links

- npm: https://www.npmjs.com/package/koa-server-http-proxy
- Repository: https://github.com/eugeneCN/koa-server-http-proxy
- Homepage: https://github.com/eugeneCN/koa-server-http-proxy#readme
- Issues: https://github.com/eugeneCN/koa-server-http-proxy/issues
- npm.io page: https://npm.io/package/koa-server-http-proxy

## Dependencies (2)

- [koa2-connect](https://npm.io/package/koa2-connect.md) ^1.0.2
- [http-proxy-middleware](https://npm.io/package/http-proxy-middleware.md) ^0.18.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2018-08-06

## README

# koa-server-http-proxy

A koa2 http-proxy-middleware.

## Installation

```bash
$ npm install koa-server-http-proxy --save
```

## Example

```js
const Koa = require('koa')

const app = new Koa()

const proxy = require('koa-server-http-proxy')

app.use(proxy('/api', {
  target: 'https://news-at.zhihu.com',
  pathRewrite: { '^/api': 'api/4/' },
  changeOrigin: true
}))

app.listen(3000)


```


## Browser

```
http://127.0.0.1:3000/api/themes
```


## Example2

```js
const Koa = require('koa')

const app = new Koa()

const proxy = require('koa-server-http-proxy')

const proxyTable = {
  '/json': {
    target: 'http://jsonplaceholder.typicode.com',
    pathRewrite: { '^/json': '' },
    changeOrigin: true
  },
  '/api': {
    target: 'https://news-at.zhihu.com',
    pathRewrite: { '^/api': 'api/4/' },
    changeOrigin: true
  }
}

Object.keys(proxyTable).forEach((context) => {
  var options = proxyTable[context]
  app.use(proxy(context, options))
})

app.listen(3000)


```


## Options

All options are passed to `http-proxy-middleware`, except that if options is passed
as a string, it will normalized as options' target.

See [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware#options) for full list of
accepted options.

## License

MIT

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