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. :(
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
You can't change that from within express. The domain name is resolved by the browser using OS system and DNS services. It is not resolved by your express application. It is resolved by the browser before any connection to your express application is made.
You could edit the host file on your local computer to define someothername as an alias for localhost. How exactly you edit the host file depends upon what OS you are running as this is an OS-specific feature.
Just to review, here's the normal steps when you request a web page in the browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With