hot-module-plugin uses my local IP as a loopback address(creating issues), not localhost
- Operating System: OSX
- Node Version: lts/carbon
- NPM Version: 6
- webpack Version: 4
- webpack-dev-server Version: 3.1.5
- [ x ] This is a bug
- [ ] This is a modification request
Code
Why does webpack use my IP for loopback as default rather than localhost? Is there a specific reason for it, or a way to change this address? The webpack-dev-middleware supports a custom path for HMR, but the webpack-dev-server equivalent doesn't seem to.
Due to some peculiar settings in my employer's mandatory VPN, this address is blocked.
Failed to load http://10.120.159.145:4001/sockjs-node/info?t=1534190167002: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4001' is therefore not allowed access. The response had HTTP status code 503.
// additional code, remove if not needed.
Expected Behavior
Using Localhost
Actual Behavior
Using my IP
Did you try with
webpack.config.js
const config = {
devServer: {
useLocalIp: false
}
}
The webpack-dev-middleware supports a custom path for HMR, but the webpack-dev-server equivalent doesn't seem to.
Yep, this it is not supported by webpack-dev-server atm, maybe better to usewebpack-dev-middleware + webpack-hot-middleware instead
The potentially provide any futher help I would need to see (the relevant parts) of your webpack.config.js and more info about your companies setup and requirements, feel free to reopen the issue if you can provide those :)
I ran into this issue as well.
I was running dev server with a specified self signed cert which used localhost as the CA. The page would load fine under localhost but any HMR requests failed because they pointed to the network address.
https: {
pfx: fs.readFileSync('../localhost.pfx'),
passphrase : 'XXXXXX',
}
Setting useLocalIp: false did not resolve the issue for me.
However, specifying the host as localhost did force the hmr requests to go through localhost.
const config = {
devServer: {
host: 'localhost',
https: {
pfx: fs.readFileSync('../localhost.pfx'),
passphrase : 'XXXXXX',
}
}
}