Skip to content

Commit

Permalink
webpackHotDev now uses wss when https is used (#8079)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecaulley authored and ianschmitz committed Dec 5, 2019
1 parent 9a817dd commit 9f4cb4f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-dev-utils/webpackHotDevClient.js
Expand Up @@ -59,7 +59,7 @@ if (module.hot && typeof module.hot.dispose === 'function') {
// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
url.format({
protocol: 'ws',
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
Expand Down

10 comments on commit 9f4cb4f

@samimhm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can I use this change in my project ? On the time of writing this comment, my dependencies are up-to-date (react-dev-utils 10.0.0, react-scripts 3.3.0), but this file is still with the old "ws", app not working with https. I have to wait until the new publish of react-dev-utils on npm (last is 15 day ago) ? I am new to coding.

@danielkita
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samimhm there is no easy way to use it before release 3.3.1. For now HMR in CRA in HTTPS mode is useless. CC: @iansu

@samimhm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Now I have a better understanding about this stuff. I've lost 2 days trying to figure it out.

@singhvaibhavram
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even after doing this I'm getting the error.

@maulikdhameliya
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need 3.3.1 badly. Right now the app is giving error on Heroku.
Please release 3.3.1

@singhvaibhavram
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. @maulikdhameliya The same issue on hosting on Heroku. Any other site you tired?

@maulikdhameliya
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singhvaibhavram: I will try on firebase today.

@ivorscott
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rusty-jnr
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singhvaibhavram same issue happened to me but I tried pushing my app on netlify and it worked perfectly

@danielmahon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until this drops you can use something like replace and add something like this to your postinstall:

(Im also adding in a valid localhost cert to avoid browser errors)

package.json

...
    "postinstall": "yarn fix:cert && yarn fix:wss",
    "fix:cert": "cp ~/localhost.pem ./node_modules/webpack-dev-server/ssl/server.pem",
    "fix:wss": "replace \"'ws'\" \"'wss'\" node_modules/react-dev-utils/webpackHotDevClient.js"
...

Please sign in to comment.