首页 > 解决方案 > create-react-app https localhost 安全连接失败

问题描述

我正在尝试在本地开发人员上使用 https 来创建“create-react-app”。我将此站点用作创建证书的教程并让 Windows 信任它:https ://zeropointdevelopment.com/how-to-get-https-working-in-windows-10-localhost-dev-environment/

这是我的 .env 文件。

SSL_CRT_FILE=client-1.local.crt
SSL_KEY_FILE=client-1.local.key
HTTPS=true

这是我的 package.json

...
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
...

之后,我使用

npm 开始

命令,然后转到 https://localhost:3000/

安全连接失败”错误,细节很少“连接到 localhost:3000.PR_CONNECT_RESET_ERROR 期间发生错误

连接被重置

我还检查了这篇文章create-react-app:如何使用 https 而不是 http?但我没有看到任何可以帮助我的东西。我有 Windows 10。

有任何想法吗 ?谢谢

标签: httpsopensslcreate-react-app

解决方案


按照官方create-react-app 网站中的解决方案,您应该运行:

set HTTPS=true&&npm start

这将为您运行“npm start”,浏览器应该允许您查看页面


推荐阅读