1

I've deployed a basic test React app to Google Cloud Provider but the following error is returned at https://{my-app}.appspot.com/:

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

I found this Issue and PR:

https://github.com/facebook/create-react-app/issues/8075 https://github.com/facebook/create-react-app/pull/8079

Both of these urls were referenced by the following article:

https://medium.com/@sydbails/create-react-app-websocket-error-and-solution-you-re-welcome-7ba9c2f48546

The author of this article mentions a workaround of changing some code directly in:

node_modules > react-dev-utils > webpackHotDevClient.js

But based on the PR that I provided in the second url of this post, doesn't a PR already exist to fix this issue? So why did the author change node_module code? But even with the workaround that the author mentioned, the following error is returned in the deployment environment:

Error: Server Error The server encountered a temporary error and could not complete your request. Please try again in 30 seconds.

What is the proper way for me to apply the PR fix for this issue?

user12617173
  • 127
  • 2
  • 10

1 Answers1

1

The error tells you your problem. Your website is hosted over https, hence the browser wont allow you to make any API or websocket calls to http or ws content because it is insecure. you need to host your websocket server with SSL over wss protocol then your code will be able to make calls. else host your website over http instead of https (bad idea). read this Difference between ws and wss?

Sujit.Warrier
  • 2,815
  • 2
  • 28
  • 47