从VirtualBox中的IE访问在mac上运行的AngularJS应用程序



在我们的开发环境中,我们的Angular应用程序在Mac上以开发模式运行(grunt serve)通过Mac上的浏览器,我们可以使用http://localhost:9000/

我们如何在VirtualBox上从IE访问它?

我们正在使用yo角发生器Gruntfile.js

connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},

更新:

VirtualBox与Windows和IE一起安装在同一台Mac上,我在那里"咕哝服务"并开发Angular应用程序

我可以使用URL从VBox中的IE访问angular应用程序:http://10.0.2.2但仍然不起作用

1) 在网络面板中

request.Name: livereload.js?snipver=1 
request.Path: http://10.0.2.2:35729/
request.Protocol: pending
request.Status (Description): pending

2) 在网络面板中,没有列出XHR请求

也许问题是该应用程序正在使用另一台通过VPN访问的服务器上的REST端点?

已解决:

问题不在于V-Box网络设置,而在于我在angular应用程序中检测localhost的方式(用于DEV目的)

我有:

var IS_LOCALHOST = (location.hostname.indexOf('localhost') > -1) 

我把它改成

var IS_LOCALHOST = (location.hostname.indexOf('localhost') > -1) || (location.hostname.indexOf('10.0.2.2') > -1);

我用它做之类的事情

var BASE_URL = IS_LOCALHOST ? 'http://dev.api.base.url' : 'http://' + location.hostname;

Virtualbox托管在哪里?我假设它运行的是某种版本的Windows,因为你问IE.

如果Virtualbox与Angular应用程序在同一台主机(物理机器)上运行,听起来你需要将VM设置为"仅主机"网络模式。请参阅:https://superuser.com/questions/303906/virtualbox-make-host-and-guest-os-talk-between-each-other

一旦您在主机和访客机器之间建立了网络,您就应该能够在Virtualbox中启动IE,并键入Mac的IP地址和端口(:9000)并进行连接。确保Grunt Serve设置为在"localhost"之外提供服务。请参阅:通过虚拟机上的localhost:port访问node.js/grumt服务器

此外,请确保没有任何防火墙规则干扰对Mac上9000端口的请求。

您可以转到windows操作系统的virtualbox网络适配器设置,并桥接这两个连接。这样你就可以通过提供mac的IP地址和端口来访问IE中的angular应用程序。http://IP_OF_MAC:Port

最新更新