不安全的 WebSocket 连接"/>
构建“WebSocket”失败:可能无法从通过 HTTPS 加载的页面启动不安全的 WebSocket 连接
我正在部署 React 应用程序,但是当我通过 https 访问页面时出现奇怪的错误。
当我通过 https 访问页面时,我收到以下错误:
SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
尝试了here中的一些解决方案,但它们没有用。
我包含了 package.json 文件的副本。如果您需要我上传任何其他代码部分以帮助调试,请告诉我。
提前致谢。
package.json
{
"name": "magnus-ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.2.0",
"bootstrap": "^5.2.3",
"history": "^5.3.0",
"jwt-decode": "^3.1.2",
"moment": "^2.29.4",
"react": "^18.2.0",
"react-awesome-button": "^7.0.4",
"react-bootstrap": "^2.6.0",
"react-datepicker": "^4.8.0",
"react-datepicker2": "^3.3.13",
"react-dom": "^18.2.0",
"react-icons": "^4.7.1",
"react-json-editor-ajrm": "^2.5.13",
"react-notifications-component": "^4.0.1",
"react-scripts": "5.0.1",
"react-select": "^5.6.1",
"url-join": "^5.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"react-router-dom": "^6.4.3"
}
}
回答如下:
更多推荐
构建“WebSocket”失败:可能无法从通过 HTTPS 加载的页面启动不安全的 WebSocket 连接
发布评论