# proxy-middleware

> http(s) proxy as connect middleware

Latest version **0.15.0** (published 2015-10-24) · MIT license · 0 weekly downloads

## Install

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

## 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.15.0 |
| Published | 2015-10-24 |
| First published | 2012-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 142 |
| Author | Andrew Kelley |
| Maintainers | superjoe |
| Keywords | connect, proxy, middleware, https, http, ssl |

## Links

- npm: https://www.npmjs.com/package/proxy-middleware
- Repository: https://github.com/andrewrk/connect-proxy
- Homepage: https://github.com/andrewrk/connect-proxy#readme
- Issues: https://github.com/andrewrk/connect-proxy/issues
- npm.io page: https://npm.io/package/proxy-middleware

## 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.15.0 (latest) — 2015-10-24
- 0.14.0 — 2015-09-03
- 0.13.1 — 2015-08-04
- 0.13.0 — 2015-06-03
- 0.12.0 — 2015-05-29
- 0.11.1 — 2015-05-08
- 0.11.0 — 2015-01-30
- 0.10.0 — 2015-01-27
- 0.9.0 — 2014-12-09
- 0.8.0 — 2014-12-04
- 0.7.0 — 2014-10-22
- 0.6.0 — 2014-10-06
- 0.5.1 — 2014-08-27
- 0.5.0 — 2013-09-08
- 0.4.0 — 2013-06-17
- … 8 more at https://npm.io/package/proxy-middleware/versions

## README

[![Build Status](https://secure.travis-ci.org/andrewrk/node-proxy-middleware.png)](http://travis-ci.org/andrewrk/node-proxy-middleware)

### Usage:

```js
var connect = require('connect');
var url = require('url');
var proxy = require('proxy-middleware');

var app = connect();
app.use('/api', proxy(url.parse('https://example.com/endpoint')));
// now requests to '/api/x/y/z' are proxied to 'https://example.com/endpoint/x/y/z'

//same as example above but also uses a short hand string only parameter
app.use('/api-string-only', proxy('https://example.com/endpoint'));
```

### Documentation:

`proxyMiddleware(options)`

`options` allows any options that are permitted on the [`http`](http://nodejs.org/api/http.html#http_http_request_options_callback) or [`https`](http://nodejs.org/api/https.html#https_https_request_options_callback) request options.

Other options:
- `route`: you can pass the route for connect middleware within the options, as well.
- `via`: by default no [via header](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.45) is added. If you pass `true` for this option the local hostname will be used for the via header. You can also pass a string for this option in which case that will be used for the via header.
- `cookieRewrite`: this option can be used to support cookies via the proxy by rewriting the cookie domain to that of the proxy server. By default cookie domains are not rewritten. The `cookieRewrite` option works as the `via` option - if you pass `true` the local hostname will be used, and if you pass a string that will be used as the rewritten cookie domain.
- `preserveHost`: When enabled, this option will pass the Host: line from the incoming request to the proxied host. Default: `false`.

### Usage with route:

```js
var proxyOptions = url.parse('https://example.com/endpoint');
proxyOptions.route = '/api';

var middleWares = [proxy(proxyOptions) /*, ...*/];

// Grunt connect uses this method
connect(middleWares);
```

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