Description
I'm submitting a bug report
webpack and webpack-dev-server version:
webpack: 1.13.2
webpack-dev-server: 1.15.1
Please tell us about your environment:
OSX 10.10.5, embedded in create-react-app 0.4.1. This is related to the issue here: facebook/create-react-app#574
Current behavior:
When the dev server is started with https: true
, the websocket attempts to connect to the a URL that doesn't include the port, e.g. https://localhost/sockjs-node/...
instead of https://localhost:3000/sockjs-node/...
.
Expected/desired behavior:
It should connect to a URL that includes a port, if the port is present. The previous version (1.14.1) worked correctly.
- If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration. Be sure to specify how you are running the server.
npm install -g create-react-app
create-react-app test-app && cd test-app
HTTPS=true npm start
- Check the console, notice that WDS is failing to connect.
To fix it:
-
From inside
test-app
, opennode_modules/react-scripts/node_modules/webpack-dev-server/client/index.js
-
Change line 62 from this:
protocol: (window.location.protocol === "https:" || urlParts.hostname === '0.0.0.0') ? window.location.protocol : urlParts.protocol,
To this:
protocol: urlParts.protocol,
I couldn't see any good way from the WebpackDevServer config to influence how this protocol is handled. It does seem like the port
attribute is being set correctly, so maybe there's a bug in url
or SockJS
that's causing the port to be ignored?
- What is the expected behavior?
WDS should connect to the server. - What is the motivation / use case for changing the behavior?
To enable HTTPS mode with the webpack-dev-server.