Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Merge requests
  • !235

prefer `target.hostname` over `target.host`

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/Filirom1/patch-1 into master Apr 24, 2012
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: Filirom1

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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/Filirom1/patch-1