且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

React应用错误:无法构造"WebSocket":可能无法通过HTTPS加载的页面启动不安全的WebSocket连接

更新时间:2021-11-24 21:19:22

这里有很多答案确实可以解决问题,但是自从我问这个问题以来,我找到的最简单的方法是添加npm包

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 servenpm i serve

,然后将启动脚本替换为以下内容:

and then replace your start script with the following:

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

这实际上是从create-react-app docs

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