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
{{ message }}
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
Node-Replay does not support a String as the first parameter of http.get, and never actually proxies requests where the first argument is a String.
Details
As per the node.js documentation around http.get, a URL string can be passed instead of an options object. Node.js then uses url.parse to separate this out as needed. Therefore the following code should work:
http.get('http://google.com')
Node-Replay does not support this, it assumes options is an object. If the properties cannot be found on the object it defaults to passing isLocalhost - e.g:
This means using http.get with a String as the first argument results in Node-Reply not proxying the request.
Solution
Detecting if the first argument is a String, and converting it to the expected object - e.g typeof options === 'string' ? url.parse(options) : options is the best solution. If you'd like I can create a PR for this, but I don't have time to do it today (with tests).
The text was updated successfully, but these errors were encountered:
Abstract
Node-Replay does not support a String as the first parameter of http.get, and never actually proxies requests where the first argument is a String.
Details
As per the node.js documentation around http.get, a URL string can be passed instead of an
options
object. Node.js then usesurl.parse
to separate this out as needed. Therefore the following code should work:Node-Replay does not support this, it assumes options is an object. If the properties cannot be found on the object it defaults to passing
isLocalhost
- e.g:This means using http.get with a String as the first argument results in Node-Reply not proxying the request.
Solution
Detecting if the first argument is a String, and converting it to the expected object - e.g
typeof options === 'string' ? url.parse(options) : options
is the best solution. If you'd like I can create a PR for this, but I don't have time to do it today (with tests).The text was updated successfully, but these errors were encountered: