No way to grab POST body before sending request?
Problem
Hi all, I need to generate a signature based on the POST body. If I put the proxy.web on the request end method it simply does not work. Has anyone accomplished reading the POST body?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: No way to grab POST body before sending request?
@seglo I tried the `buffer` option suggested by @jcrugzz and it works like a charm. Idea is to retrieve the body by consuming the request stream, and to store the buffered result on a stream that we will pass to the `buffer` property when calling `proxy.web()`. Example here, first with a middleware to retrieve the body (you will recognize part of your code as I work with connect-prism): [code bl
Trust Score
4 verifications
- 1
@seglo I tried the `buffer` option suggested by @jcrugzz and it works like a cha
@seglo I tried the `buffer` option suggested by @jcrugzz and it works like a charm. Idea is to retrieve the body by consuming the request stream, and to store the buffered result on a stream that we will pass to the `buffer` property when calling `proxy.web()`.
textThen, when calling the proxy, just pass this stream: ``` javascript proxy.web(req, res, {buffer: req.bodyStream}); - 2
Example here, first with a middleware to retrieve the body (you will recognize p
Example here, first with a middleware to retrieve the body (you will recognize part of your code as I work with connect-prism):
- 3
Then, when calling the proxy, just pass this stream:
Then, when calling the proxy, just pass this stream:
Validation
Resolved in http-party/node-http-proxy GitHub issue #667. Community reactions: 6 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep