简体   繁体   中英

adding subdomain to localhost expressjs

I am working on expressjs application. locally my application run on http://localhost:3000 , I want to run this application on http://localhost.mycomp.com as well.

is it possible to achieve this without editing /etc/hosts/ file ?

Without using /etc/hosts it would be possible only if the DNS for mycomp.com would have 127.0.0.1 in the A record of the localhost.mycomp.com subdomain - which is unlikely as that would be very insecure.

Other than that you could run a local name resolver that does that but this is basically just like using /etc/hosts but harder. Or you could route IP traffic for the IP that localhost.mycomp.com resolves to (if it exists) to your own loopback or other local interface but that would be even harder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM