Description
Bug report
Currently, using webpack-dev-server
with --host ::
and --open
options results in an ERR_ADDRESS_INVALID
error in browsers (Chrome, Edge, etc.) on Windows.
The reason is that we are sending http://[::]
to the browser and the IPv6 unspecified address ::
is considered an invalid host address on Windows.
Note that on macOS and Linux, ::
is automatically mapped to ::1
and 0.0.0.0
is automatically mapped to 127.0.0.1
. So we have this problem only on Windows.
Interestingly, although 0.0.0.0
is also considered invalid on Windows, using --host 0.0.0.0
with --open
is fine because we are replacing the IPv4 unspecified address 0.0.0.0
with localhost
before opening the browser.
So, to fix the problem, we can do the same thing for the IPv6 address: replace ::
with localhost
when the --open
option is used.
Besides, on GitHub Codespaces, if we use localhost
, the browser opening event will be intercepted and redirected correctly. If we use ::
, the browser will be redirected to the wrong address.
I am working on a PR to fix the problem.
Actual Behavior
When running webpack-dev-server --host :: --open
, http:://[::]
is sent to the browser.
Expected Behavior
When running webpack-dev-server --host :: --open
, http://localhost
is sent to the browser.
How Do We Reproduce?
Execute an example with the options --host ::
and --open
on Windows:
$ cd examples/api/simple
$ webpack-dev-server --host :: --open
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Windows 10 10.0.20348
CPU: (1) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
Memory: 414.89 MB / 1023.61 MB
Binaries:
Node: 20.1.0 - C:\Program Files\nodejs\node.EXE
npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Internet Explorer: 11.0.20348.380
Google Chrome: 113.0.5672.93
Microsoft Edge: 113.0.1774.35
Related: #1233