React app error: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS

后端 未结 8 1589
南方客
南方客 2020-12-01 10:29

I am deploying a React app but am getting a strange error when I visit the page over https.

When I visit the page over https I receive the following error:

S

8条回答
  •  盖世英雄少女心
    2020-12-01 11:03

    It's been a while since I was messing around with react, but react-scripts is built on top of webpack if I'm not mistaken, so it most likely use webpack-dev-server to speed up development. It uses websockets in order to communicate to the client to trigger a hot reload when it discovers changes on disk.

    You are probably just starting the application in development mode, so if you're deploying it to a production environment, you should run npm run build which would create a set of javascript files that you can serve with your favourite webserver.

提交回复
热议问题