Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer target.hostname over target.host #235

Merged
merged 1 commit into from
Jul 22, 2012

Conversation

Filirom1
Copy link
Contributor

Hi,

I struggled to debug an Error: getaddrinfo ENOENT.

I parsed my target string with url

> require('url').parse('http://127.0.0.1:3000/')
{ protocol: 'http:',
  slashes: true,
  host: '127.0.0.1:3000',
  port: '3000',
  hostname: '127.0.0.1',
  href: 'http://127.0.0.1:3000/',
  pathname: '/',
  path: '/' }

And pass this object to node-http-proxy.

Then the following code is executed :

outgoing.host    = this.target.host;
outgoing.port    = this.target.port;

reverseProxy = this.target.protocol.request(outgoing, function (response) {

But host === '127.0.0.1:3000', and it fails.

That's why I would prefer

outgoing.hostname    = this.target.hostname;

because hostname always === '127.0.0.1'

This is also a nodejs recommendation:

http://nodejs.org/api/http.html#http_http_request_options_callback

host: A domain name or IP address of the server to issue the request to. Defaults to 'localhost'.
hostname: To support url.parse() hostname is preferred over host

indexzero added a commit that referenced this pull request Jul 22, 2012
prefer `target.hostname` over `target.host`
@indexzero indexzero merged commit f28c62c into http-party:master Jul 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants