divhide/node-grunt-http-server

Unable to bind server

Closed this issue · 2 comments

I am using following configuration !

"http-server": {
      dev: {
        root: "src",
        port: 8080,
        host: "127.0.0.1",
        cache: -1,
        showDir: true,
        autoIndex: true,
        ext: "html",
        runInBackground: true,
        headers: {
          "Access-Control-Allow-Origin": "*",
          "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
        }
      }
    }

my server is running well and I can access it with

http://localhost:8080/init.js etc

But I cannot access this server from any my mobile. (My PC and mobile are in same wifi network).

So I changed the configuration to this (assigned my ip address in hardcode manner)

 host: "192.168.1.94",

Now I can access it from other system from my mobile as well, using

http://192.168.1.94:8080/init.js etc

But when I do this, I am unable to access it from localhost host,
I cannot do this -

http://localhost:8080/init.js etc

So, I want some kind of configuration that it bind on both, IP as well as localhost !!

Also, My ip address changes everytime, so it is difficult update the GruntFile everytime,

is it possible to have

 host: "*"

kind of configuration ?

Hi @nsisodiya,

You have to set the host to "0.0.0.0". That way it will be available to the outside.

I've updated the project documentation and the version to 1.2.0 on npm which contains updated dependencies.

Hope it helps.

thanks