• 欢迎订阅我的Youtube频道
  • 欢迎加入我的电报群

Access your angular2 dev environment from VPN without remote desktop

Uncategorized fennng 2年前 (2018-02-16) 859次浏览 0个评论
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
Inline image 4
Inline image 2
Make sure you enable capturing
Inline image 3
And also make sure your proxy setting doesn’t bypass localhost
Inline image 5
Inline image 1
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.
Next post, I will show you how to edit angular2 source code without a remote desktop.

峰享技术 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Access your angular2 dev environment from VPN without remote desktop
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址