我正在尝试在本地开发上使用 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 start
命令,然后转到 https://localhost:3000/
- 在 Firefox 上我收到了
Secure Connection Failed" error with very few details "An error occurred during a connection to localhost:3000.PR_CONNECT_RESET_ERROR
- 在 Chrome 上我收到
The connection was reset
我还检查了这篇文章create-react-app: how to use https instead of http?但我没有看到任何可以帮助我的东西。 我有 Windows 10。
有什么想法吗? 谢谢
最佳答案
我在 Edge 上也遇到了类似的问题。这就是我解决这个问题的方法,
- 在 Edge 浏览器中输入 URL:- edge://net-internals/#hsts
- 在“删除域安全策略”中输入“localhost”,然后按“删除”。
- 重新开放 localhost:3000/
*chrome也有类似的链接chrome://net-internals/#hsts
关于https - create-react-app https localhost 安全连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65834614/