Description
macOS El Capitan
angular-cli: 1.0.0-beta.21
node: 6.9.1
os: darwin x64
I'm running ng serve
within a Vagrant box. I configured Nginx following these instructions. Everything works as expected when I forward port 4200 in Vagrant, but it fails with any other port, with this error:
[WDS] Disconnected!
GET http://localhost:4200/sockjs-node/info?t=1480728685812 net::ERR_CONNECTION_REFUSED
I understand why this happens, it's because in the guest I reverse proxy port 4200 to port 80 which is exposed as port 1234 in the host, like:
config.vm.network 'forwarded_port', guest: 80, host: 1234
In order to get it working I need the following:
GET http://localhost:1234/sockjs-node/info?t=1480728685812
I found out the code that handles this in server-webpack.ts, line 38:
`webpack-dev-server/client?http://${serveTaskOptions.host}:${serveTaskOptions.port}/`
I need to hardcode serveTaskOptions.port
to 1234
make it work.
I think Webpack's --public
option may help, but it is not exposed to ng serve
. Any ideas how to get this working without the hack? Perhaps exposing a different port option for port forwarding, since the guest port where webpack is running may not be the same port in the host?