Search code examples
node.jsexpresslocalhostgruntfile

changing the name of localhost web app express?


I'm working on a project, and I NEED to change the name of the project from localhost:9000 to someothername:9000, this is in my development environment, not production.

I was given the project files, and the person (who is no longer here) used express.js. I've searched and searched for the answer to this, but I cannot figure it out.

So, is it possible to change the name of localhost:9000 to someothername:9000 using express.js or updating the gruntfile? I know that I can change the localhost settings on my computer, but I need for there to be an alias that occurs through the web application.

I'm ready to rip my hair out. :(


Solution

  • as you are on development environment, its enough to add

    127.0.0.1  testurl.test
    

    on the bottom of

    C:\Windows\System32\drivers\etc\hosts
    

    now to set the port of the server to 80 (standartport for http) you need to change

    project\bin\www
    

    (ejs standart line 15)

    var port = normalizePort(process.env.PORT || '3000');
    

    to

    var port = normalizePort(process.env.PORT || '80');
    

    now, if you type testurl.test in your browser, it should show you the website.

    this works for windows, if you have an mac or linux, just change the hosts file as you need.

    Marius