在我们的开发环境中,我们的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安装在同一台苹果电脑上,我就是在这台电脑上“呼呼服务”并开发Angular应用程序的
我可以在VBox中使用URL:http://10.0.2.2从IE访问angular应用程序,但仍有一些东西无法工作
1)在网络面板中
request.Name: livereload.js?snipver=1
request.Path: http://10.0.2.2:35729/
request.Protocol: pending
request.Status (Description): pending
2)在网络面板中没有列出XHR请求
也许问题是应用程序正在使用REST端点,这些端点位于通过VPN访问的另一台服务器上?
已解决:
问题不在于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;
发布于 2016-06-08 22:03:14
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”之外提供服务。看看这个:Access node.js/grunt server through localhost:port on virtual machine
此外,请确保没有任何防火墙规则会干扰对Mac上9000端口的请求。
发布于 2016-06-09 15:57:24
您可以转到windows操作系统的virtualbox网络适配器设置,然后桥接这两个连接。这样,你就可以通过给出mac的IP地址和端口来访问IE内部的angular应用程序。http://IP_OF_MAC:Port
https://stackoverflow.com/questions/37713577
复制相似问题