Skip to content

Commit 0497805

Browse files
Tiggechimurai
authored andcommitted
Bump http-proxy version to 1.17.0 (#261)
The http-proxy was recently updated with many features and bug fixes. This commit brings in the latest version and updates the README.md file with new (and missing) options.
1 parent 7a5bf5e commit 0497805

File tree

3 files changed

+67
-6
lines changed

3 files changed

+67
-6
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ The following options are provided by the underlying [http-proxy](https://github
309309
* **option.ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request (note: you will have to append / manually if required).
310310
* **option.localAddress** : Local interface string to bind for outgoing connections
311311
* **option.changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL
312+
* **option.preserveHeaderKeyCase**: true/false, Default: false - specify whether you want to keep letter case of response header key
312313
* **option.auth** : Basic authentication i.e. 'user:password' to compute an Authorization header.
313314
* **option.hostRewrite**: rewrites the location hostname on (301/302/307/308) redirects.
314315
* **option.autoRewrite**: rewrites the location host/port on (301/302/307/308) redirects based on requested host/port. Default: false.
@@ -325,8 +326,41 @@ The following options are provided by the underlying [http-proxy](https://github
325326
"*": ""
326327
}
327328
```
329+
* **option.cookiePathRewrite**: rewrites path of `set-cookie` headers. Possible values:
330+
* `false` (default): disable cookie rewriting
331+
* String: new path, for example `cookiePathRewrite: "/newPath/"`. To remove the path, use `cookiePathRewrite: ""`. To set path to root use `cookiePathRewrite: "/"`.
332+
* Object: mapping of paths to new paths, use `"*"` to match all paths.
333+
For example, to keep one path unchanged, rewrite one path and remove other paths:
334+
```
335+
cookiePathRewrite: {
336+
"/unchanged.path/": "/unchanged.path/",
337+
"/old.path/": "/new.path/",
338+
"*": ""
339+
}
340+
```
328341
* **option.headers**: object, adds [request headers](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields). (Example: `{host:'www.example.org'}`)
329342
* **option.proxyTimeout**: timeout (in millis) when proxy receives no response from target
343+
* **option.timeout**: timeout (in millis) for incoming requests
344+
* **option.followRedirects**: true/false, Default: false - specify whether you want to follow redirects
345+
* **option.selfHandleResponse** true/false, if set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the `proxyRes` event
346+
* **option.buffer**: stream of data to send as the request body. Maybe you have some middleware that consumes the request stream before proxying it on e.g. If you read the body of a request into a field called 'req.rawbody' you could restream this field in the buffer option:
347+
348+
```
349+
'use strict';
350+
351+
const streamify = require('stream-array');
352+
const HttpProxy = require('http-proxy');
353+
const proxy = new HttpProxy();
354+
355+
module.exports = (req, res, next) => {
356+
357+
proxy.web(req, res, {
358+
target: 'http://localhost:4003/',
359+
buffer: streamify(req.rawBody)
360+
}, next);
361+
362+
};
363+
```
330364
331365
332366

package-lock.json

+32-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"ws": "^5.0.0"
6060
},
6161
"dependencies": {
62-
"http-proxy": "^1.16.2",
62+
"http-proxy": "^1.17.0",
6363
"is-glob": "^4.0.0",
6464
"lodash": "^4.17.5",
6565
"micromatch": "^3.1.9"

0 commit comments

Comments
 (0)