Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

All requests to proxy are http://[object Object]:undefined #16

Open
dougludlow opened this issue Apr 13, 2016 · 6 comments
Open

All requests to proxy are http://[object Object]:undefined #16

dougludlow opened this issue Apr 13, 2016 · 6 comments

Comments

@dougludlow
Copy link

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.

@sudiphed
Copy link

sudiphed commented May 4, 2016

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;

@jonoward
Copy link

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);
};

@dimasmjunior
Copy link

I can confirm this on node v6.7.0.

@maxrydkin
Copy link

One note on @jonoward's workaround solution: you may need to do the same for https.globalAgent if you make https calls

@mhimmer
Copy link

mhimmer commented Mar 30, 2017

Also confirmed on node v7.7.3

@gpoole
Copy link

gpoole commented Aug 8, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants