Skip to content

[WDS] Disconnected! with HTTPS and nonstandard port #592

Closed
@dceddia

Description

@dceddia

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.
  1. npm install -g create-react-app
  2. create-react-app test-app && cd test-app
  3. HTTPS=true npm start
  4. Check the console, notice that WDS is failing to connect.

To fix it:

  • From inside test-app, open node_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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions