Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,17 @@ proxyServer.listen(8015);
* **headers**: object with extra headers to be added to target requests.
* **proxyTimeout**: timeout (in millis) for outgoing proxy requests
* **timeout**: timeout (in millis) for incoming requests
* **followRedirects**: true/false, Default: false - specify whether you want to follow redirects
* **followRedirects**: specify whether you want to follow redirects. Possible values:
* `false` (default): do not follow redirects
* `true`: follow redirects and use default options
* Object: specify options for following redirects.
For example:
```
followRedirects: {
maxRedirects: 10,
maxBodyLength: 20 * 1024 * 1024
}
```
* **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
* **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:

Expand Down
5 changes: 5 additions & 0 deletions lib/http-proxy/passes/web-incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ module.exports = {
// And we begin!
server.emit('start', req, res, options.target || options.forward);

if (options.followRedirects) {
followRedirects.maxRedirects = options.followRedirects.maxRedirects || followRedirects.maxRedirects;
followRedirects.maxBodyLength = options.followRedirects.maxBodyLength || followRedirects.maxBodyLength;
}

var agents = options.followRedirects ? followRedirects : nativeAgents;
var http = agents.http;
var https = agents.https;
Expand Down