Hide port in address bar when run NodeJS locally on Windows

Hide port in address bar when run NodeJS locally on Windows



As we know, when we run NodeJS on hosting server and want to hide port like :3000 from the browser address bar, we can set up ngnix or use in .htaccess the rules like


:3000


ngnix


.htaccess


RewriteEngine On
RewriteRule ^$ http://example.com:3000/ [P,L]
RewriteCond %REQUEST_FILENAME !-f
RewriteCond %REQUEST_FILENAME !-d
RewriteRule ^(.*)$ http://example.com:3000/$1 [P,L]



But what about running NodeJS locally on Windows? Is it possible to hide the port in the browser address bar in this case? I mean without additional server



ps. I run Windows binary 64-bit version of NodeJS on Windows 7






You can't. The nginx rewrite rule you mentioned is just serving your file from localhost:3000 at localhost:80 (or 443) (the default http/https port number which can be omitted). That's not exactly "hiding ports". That's nginx serving at the front while remapping the resource for incoming requests.

– viz
Sep 10 '18 at 18:21







If you want to "hide" the ports, you need to run your node js server at default http/https ports, which requires the program run in sudo. Such way is not recommended and you should use with a web server service like nginx, apache, etc. in the front instead if you're in production.

– viz
Sep 10 '18 at 18:25







Oh, it turns out when we run NodeJS locally it's enough to specify port 80 in my JS file to "hide" the port from the address bar. Do you mean "such way is not recommended" when we run NodeJS locally or on hosting?

– stckvrw
Sep 10 '18 at 18:38






It depends on your context. It normally requires "Administrator's privilege"(in windows) or sudo(in bsd) in order to bind your application at 80/443 port. If your server application runs in a sudo mode to use these ports(which can modify system settings etc.), your system will become vulnerable in terms of security.

– viz
Sep 10 '18 at 18:43







I've just specified port 80 in my JS file, run it under the standard user account without "Administrator's privilege" and now there is no need to add a port in the address bar. It seems every third-part app based on NodeJS can harm OS regardless of the user mode since it has the access to file system.

– stckvrw
Sep 10 '18 at 19:05




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ