昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期六, 二月 17, 2018

Access your angular2 dev environment from VPN without remote desktop

Sometimes, Remote desktop is quite slow, access angular2 directory from a browser may be better.

By default, ng serve only bind to 127.0.0.1, which means the http port can only be accessed by local machine.

To allow connection from other machines, use the following command to allow all connections.
ng serve --host 0.0.0.0

Now, you will be able to access your angular2 app using ip address (e.g. 192.168.0.50:4200) from another machine. But it may not work properly. because your debug settings has all the config pointing to localhost,  your anguar2 app will make api calls to your backend using localhost rather than your ip address. To solve this problem, we can use Fiddler.

Go to Fiddler's Tools->Hosts, map localhost to your dev machine's ip address








Make sure you enable capturing




And also make sure your proxy setting doesn't bypass localhost









That's all, you are ready to go. Use localhost:4200 to access your dev angular2 app from another PC.  Because all HTTP traffic will go through fiddler, fiddler will forward all localhost traffic to your dev machine including api calls.

I will show you how to edit angular2 source code without a remote desktop.


--
Feng

没有评论:

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
这里进入我的MSN SPACE.