node.jsangularhostingdevelopment-environment

Opening locally running Angular Site on other devices in Network?


I'm running Angular Web Site on my local machine.
I run the command on vs code terminal
ng serve -o

Its automatically bundles my website and open the link http://localhost:4200/
Is there any way, that I can open the same website on my mobile phone as well?

  1. I tried it with a package https://www.npmjs.com/package/http-server it works but I need to add a package and manually run it for a site. Secondly it just host files not the bundled Angular Web Site.

  2. Someone referred me this blog post but Its complex and require extra setup.


Solution

  • Maybe run it with ng serve --host 0.0.0.0. That will let you load the site outside of localhost. On your mobile device, open a browser and set the url as something like http:://YOUR_SERVER_HOSTNAME:4200. You device and the server should be on the same network or the device should be able to resolve YOUR_SERVER_HOSTNAME.