Sunday 29 December 2019

react app error - SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection

-- Error message

SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

enter image description here

----- Solution
 1. go to : node_modules/react-dev-utils/webpackHotDevClient.js file
  2. Update 62 line 

 // 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
    pathname: '/sockjs-node',
  })
);

No comments: