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
When filtering/matching body (for a POST request), nock correctly parses it as JSON, but once the route matched, the reply function does not receive a parsed requestBody, but string representation only.
This is due to RequestOverrider not taking real request headers into account (using options.headers instead of req.headers). Some library (i'm using superagent), or usage of those, does not define headers in options, but mutates request with setHeader() before playing it.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!
lockbot
locked as resolved and limited conversation to collaborators
Sep 13, 2018
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When filtering/matching body (for a POST request), nock correctly parses it as JSON, but once the route matched, the reply function does not receive a parsed requestBody, but string representation only.
This is due to RequestOverrider not taking real request headers into account (using options.headers instead of req.headers). Some library (i'm using superagent), or usage of those, does not define headers in options, but mutates request with setHeader() before playing it.
Could we change options.headers to req.headers ?
nock/lib/request_overrider.js
Line 289 in a1fff39
nock/lib/request_overrider.js
Line 316 in a1fff39
The text was updated successfully, but these errors were encountered: