Skip to content

Using pow (virtual host proxy) causes websocket error #853

Closed
@thom-nic

Description

Description

When using pow with create-react-app's dev server configuration, the dev server attempts to make a websocket connection via the virtual host (e.g. uses window.location.hostname.) Pow does not handle websocket proxying, thus the dev server client connection needs to be made directly to localhost:[dev server port].

Observed behavior

The dev server websocket connection fails, resulting in the following browser console error:

WebSocket connection to 'ws://foo.dev/sockjs-node/414/5glaoex2/websocket' failed: Connection closed before receiving a handshake response

after which it appears to fall back to the xhr long poll method.

Desired behavior

With the standard webpack dev server HMR setup one would configure the client URL for the websocket to use. e.g. in webpack.config.dev.js:

  entry: [
    // create-react-app uses this:
    // require.resolve('react-dev-utils/webpackHotDevClient'),
    // "standard" approach:
    'webpack-dev-server/client?http://localhost:9999',
    'webpack/hot/only-dev-server',
    'app.js',
  ],

So while browsing the app at foo.dev the client websocket connection is made to localhost:9999 and everything is peachy. This is not currently possible with react-dev-utils/webpackHotDevClient meaning if a user wants to use create-react-app and pow together, they must either...

  1. eject and swap out react-dev-utils/webpackHotDevClient for the standard dev tools HMR configuration, or
  2. put up with the console error in the browser - which is not ideal because it's more difficult for a user at a glance to determine if there are actual application errors in the client.

Feature request: Add ability to specify the direct dev server URL in the client entrypoint similar to 'webpack-dev-server/client?http://localhost:9999'.

Environment

create-react-app version: 0.2.0

Reproducible Demo

# install/ setup pow
create-react-app myApp
echo 3000 > ~/.pow/foo
npm start & open http://foo.dev

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions