-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Web socket connections from an Electron BrowserWindow always have a origin
header of file://
. Connections to the devServer websocket server are always rejected unless you set allowedHosts: "all"
.
This is because this code always fails, returning a Invalid Host/Origin header
error. Digging into the code a bit, it's because this code always resolves hostname
as ''
for origin: file://
, meaning that it's impossible to add anything to allowedHosts
that would match in this loop.
I suggest modifying the logic of this method to treat file://
as localhost
.
- This is a bug
- This is a modification request
Code
N/A
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 4.98 GB / 31.02 GB
Binaries:
Node: 14.17.3 - /usr/local/bin/node
Yarn: 1.22.5 - ~<redacted>/node_modules/.bin/yarn
npm: 6.14.13 - /usr/local/bin/npm
Browsers:
Chrome: 93.0.4577.63
Firefox: 91.0.2
Packages:
fork-ts-checker-webpack-plugin: ^6.3.3 => 6.3.3
optimize-css-assets-webpack-plugin: ^6.0.1 => 6.0.1
terser-webpack-plugin: ^5.2.3 => 5.2.3
tsconfig-paths-webpack-plugin: ^3.5.1 => 3.5.1
webpack: ^5.52.0 => 5.52.0
webpack-bundle-analyzer: ^4.4.2 => 4.4.2
webpack-cli: ^4.8.0 => 4.8.0
webpack-dev-server: ^4.1.1 => 4.1.1
webpack-merge: ^4.2.2 => 4.2.2
Expected Behavior
That I can specify something in allowedHosts
to be able to accept requests from Electron BrowserWindows where origin
header is file://
.
Actual Behavior
This is not possible
For Bugs; How can we reproduce the behavior?
N/A
For Features; What is the motivation and/or use-case for the feature?
To be able to use webpack dev server without having to have the websocket server open to the world.