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

后端 未结 8 1585
南方客
南方客 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:06

    A lot of answers here do actually solve the issue but the simplest way I have found since I asked this question is to add npm package serve to your dependencies.

    yarn add serve or npm i serve

    and then replace your start script with the following:

    "scripts": {
        "start": "serve -s build",
    }
    

    This is actually straight out of the create-react-app docs

提交回复
热议问题