How can I allow access outside the localhost at Angular2? I can navigate at localhost:3030/panel
easily but I can not navigate when I write my IP such as
I just edit angular.json
file in my project as below and it works
...
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "project:build",
"host": "0.0.0.0"
},
...
For the people who are using node project manager, also this line adding to package.json will be enough. For angular CLI users, mast3rd3mon's answer is true.
You can add
"server": "webpack-dev-server --inline --progress --host 0.0.0.0 --port 3000"
to package.json
you can also introspect all HTTP traffic running over your tunnels using ngrok
, then you can expose using ngrok http --host-header=rewrite 4200
For the problem was Firewall. If you are on Windows, make sure node is allowed through
Using ng serve --host 0.0.0.0
will allow you to connect to the ng serve
using your ip instead of localhost
.
EDIT
In newer versions of the cli, you have to provide your local ip address instead
EDIT 2
In newer versions of the cli (I think v5 and up) you can use 0.0.0.0
as the ip again to host it for anyone on your network to talk to.
run command
ng serve --host=0.0.0.0 --disable-host-check
this will disable host check and allow to access from outside(instead of localhost) with IP address