You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -376,7 +376,24 @@ proxyServer.listen(8015);
376
376
* **proxyTimeout**: timeout (in millis) for outgoing proxy requests
377
377
* **timeout**: timeout (in millis) for incoming requests
378
378
* **selfHandleRequest** true/false, if set to true, none of the webOutgoing passes are called and its your responsibility ro appropriately return the response by listening and acting on the `proxyRes` event
379
+
* **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:
379
380
381
+
```
382
+
'use strict';
383
+
384
+
const streamify = require('stream-array');
385
+
const HttpProxy = require('http-proxy');
386
+
const proxy = new HttpProxy();
387
+
388
+
module.exports = (req, res, next) => {
389
+
390
+
proxy.web(req, res, {
391
+
target: 'http://localhost:4003/',
392
+
buffer: streamify(req.rawBody)
393
+
}, next);
394
+
395
+
};
396
+
```
380
397
**NOTE:**
381
398
`options.ws` and `options.ssl` are optional.
382
399
`options.target` and `options.forward` cannot both be missing
@@ -386,6 +403,7 @@ If you are using the `proxyServer.listen` method, the following options are also
386
403
* **ssl**: object to be passed to https.createServer()
387
404
* **ws**: true/false, if you want to proxy websockets
0 commit comments