gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Use 'localhost' instead of '0.0.0.0' in target URL #170

Closed timkendrick closed 9 years ago

timkendrick commented 9 years ago

http://0.0.0.0/ is not a routable address, according to https://code.google.com/p/chromium/issues/detail?id=428046.

This was causing problems when using the combination of '{ hostname: "*", open: true }' with newer versions of Chrome.

timkendrick commented 9 years ago

The Travis build was failing in Node 0.12 due to the port scanning. I'll submit a pull request to fix that first.

vladikoff commented 9 years ago

The point of using 0.0.0.0 was to make sure the server is available on the local network. If you have time could you please test that your patch makes that possible? Also thanks for taking the time to fix the port scanning!

timkendrick commented 9 years ago

I'm not sure how I'd be able to test that – my patch only changes the URL that is launched by the open module, it's not used by connect at all. Any existing tests for local network availability should be unaffected.

The build is failing at the moment, but I can re-push once pull request #171 has been accepted.

vladikoff commented 9 years ago

I'm not sure how I'd be able to test that

@timkendrick just test locally if you can.

I'll also check it in a bit...

timkendrick commented 9 years ago

Yep, just tested from other computers on my local network and everything works as it should (i.e. they can connect to my computer when I specify hostname: "*", but they can't connect when I specify hostname: "localhost").

vladikoff commented 9 years ago

@timkendrick we might need to update the doc here: https://github.com/gruntjs/grunt-contrib-connect/blob/master/docs/connect-options.md#hostname

(README docs are generated from /docs when you run grunt)

timkendrick commented 9 years ago

FYI: the lines I changed are only called after the server has been started successfully.

This means that my changes only affect two things:

All of the server-initializing functionality should be completely unaffected.

timkendrick commented 9 years ago

Yeah, I'm not sure whether the documentation for hostname is misleading or not. My (probably fairly shaky) understanding of that setting is that it's currently used for a combination of two separate things:

  1. The permitted hostname by which the server can be accessed
  2. A means to help auto-generate the URL that is launched if open: true is specified

...to my mind, a value of "*" or "0.0.0.0" sounds like a perfectly valid default for the hostname setting if that's what you're asking.

Should I add a note to the documentation saying that if open: true is specified, the URL that is launched is autogenerated based on on the hostname, defaulting to localhost for wildcard URLs?

AmirSavand commented 7 years ago

I used yoman generator for angularjs, when I change the host to 0.0.0.0 it opens that instead of localhost or the custom ip...