All requests to proxy are http://[object Object]:undefined
Opened this issue · 6 comments
I installed the global-tunnel npm module and initialized the proxy as instructed in the docs:
var globalTunnel = require('global-tunnel');
globalTunnel.initialize({
host: '127.0.0.1',
port: 8888,
});
Requests are being routed to the proxy (Charles) just fine, however they all show up as http://[object Object]:undefined
and are obviously failing.
Ran into the same thing with Node 6.
Change lib/agents.js line 51
req.path = this.proxy.innerProtocol + '//' + host.host + ':' + host.port + req.path;
Might won't work in all scenarios (e.g. if you use a custom agent), but this bit of monkey-patching on the global agent solved this issue for me for the time being. Obviously would be nice to have this fixed more formally:
globalTunnel.initialize({
host: '127.0.0.1',
port: 8888
});
var origAddRequest = http.globalAgent.addRequest;
http.globalAgent.addRequest = function(req, host, port, localAddress) {
return origAddRequest.call(this, req, host.host, host.port, localAddress);
};
I can confirm this on node v6.7.0.
One note on @jonoward's workaround solution: you may need to do the same for https.globalAgent if you make https calls
Also confirmed on node v7.7.3
It's an issue with the tunnel dependency being out of date and not being compatible with more recent versions of Node. #17 fixes it, but it looks like the best option is to use the global-tunnel-ng fork since this module seems to be dead.