1

In our development environment we have our Angular app running on a Mac in development mode (grunt serve) From a browser on the Mac we can access it with http://localhost:9000/

How can we access it from IE on a VirtualBox?

We are using yo angular generator Gruntfile.js

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

UPDATE:

The VirtualBox is installed, with Windows and IE, on the same Mac where I "grunt serve" and develop the Angular app

I can access the angular app from IE within VBox using URL: http://10.0.2.2 But something is still not working

1) In the Network panel

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

2) In the Network panel there are no XHR requests listed

Maybe the problem is that the app is using REST endpoints which are on another server which is accessed through VPN ?

SOLVED:

The problem was not with V-Box network setup but with the way I was detecting localhost in the angular app (for DEV purposes)

I had:

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

I changed it to

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

I use it for things like

var BASE_URL = IS_LOCALHOST ? 'http://dev.api.base.url' : 'http://' + location.hostname;
klode
  • 10,821
  • 5
  • 34
  • 49

2 Answers2

0

Where is the Virtualbox hosted? I'm assuming it's running some version of Windows since you ask about IE.

If the Virtualbox is running on the same host (physical machine) as the Angular app, it sounds like you need to set the VM to "host-only" networking mode. See this: https://superuser.com/questions/303906/virtualbox-make-host-and-guest-os-talk-between-each-other

Once you have networking between the host and guest machines, you should be able to launch IE in the Virtualbox and type the IP address of the Mac and the port (:9000) and connect. Make sure Grunt Serve is set to serve outside of "localhost." See this: Access node.js/grunt server through localhost:port on virtual machine

Also, make sure there aren't any firewall rules to interfere with requests to port 9000 on your Mac.

Community
  • 1
  • 1
slasky
  • 2,726
  • 4
  • 27
  • 36
  • the Virtualbox is hosted on the same mac where I run "grunt serve". Yes is running Windows 10. – klode Jun 09 '16 at 15:38
0

You can go to virtualbox network adapter settings for the windows OS and bridge both the connections. This way you will be able to access the angular app inside IE by giving the IP address, port of mac. http://IP_OF_MAC:Port

Rahul Malu
  • 556
  • 2
  • 9