Giter Club home page Giter Club logo

Comments (5)

tapio avatar tapio commented on July 24, 2024 5

The code used the resulting IP address of the given host string as the open url. I've now changed it in c94694b to use the user supplied string so that live-server --host=localhost really opens the browser at literally the string "localhost".

from live-server.

mattborn avatar mattborn commented on July 24, 2024

👍

This affects how I load fonts and whitelisted domains in my font provider. 127.0.0.1 doesn’t load the fonts. localhost does. I could change the whitelists for all of my font kits, but it would be much easier if this just worked out-of-the-box without having to manually change 127.0.0.1 to localhost in the address bar. Otherwise the default open: true feature gets in the way.

In the live-server/index.js file, I see these relevant lines:

101 · LiveServer.start = function(options) {
…
103 · var host = options.host || '0.0.0.0';
…
136 · var address = server.address();
137 · var serveHost = address.address === "0.0.0.0" ? "127.0.0.1" : address.address;
138 · var serveURL = 'http://' + serveHost + ':' + address.port;
…
211 · };

Not sure the best way to fix this without a better understanding of why this is constructed this way to begin with, otherwise I would make a PR.

from live-server.

tapio avatar tapio commented on July 24, 2024

It was localhost first, but it had problems (see #7). Apparantly there is no one address that works properly everywhere. :(

from live-server.

mattborn avatar mattborn commented on July 24, 2024

@tapio I get that different environments (OS and browsers) and use cases (http server, websockets, livereload, etc.) each have their own concerns and limitations so it’s prudent to provide a sane default, but I think this issue suggests an explicit host value should not be converted back to one of the defaults (either 127.0.0.1 or 0.0.0.0). It should be considered a bug if setting a host value doesn’t work either as a command-line argument or in the ~/.live-server.json.

from live-server.

mattborn avatar mattborn commented on July 24, 2024

@tapio ❤️

from live-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.