Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack-Dev-Server Throwing Error when Accessed from VirtualBox

I am trying to test my website compatibility for Internet Explorer 11, using VirtualBox in my Mac. I ran a local server using Webpack-Dev-Server.

When I accessed the web page via http://10.0.2.2:8080, the site is loaded fine; but the inspector panel keep throwing this error repeatedly:

SCRIPT7002: XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd. 

[WDS] Disconnected!

Any clues how to fix this error? Thanks!

like image 966
Danny Avatar asked May 11 '16 23:05

Danny


2 Answers

There may be many reasons, one may be in frontend paths:

In my setup the webpack server was proxying into Symfony server at localhost:8000. At frontend, I had that path in a config variable:

var configuration = {
    apiPath: 'http://localhost:8000/api/v1/'
}

That caused requests into localhost:8000 inside VirtualBox. I changed it to have VirtualBox localhost bridge path:

var configuration = {
    apiPath: 'http://10.0.2.2:8000/api/v1/'
}

With that change I got my app working in VirtualBox.

like image 77
Heikki Hannula Avatar answered Nov 13 '22 02:11

Heikki Hannula


You need to set localhost to 10.0.2.2 in your hosts file. This answer shows how.

like image 1
Jay Avatar answered Nov 13 '22 00:11

Jay