ssl Localhost https中断与nodeJS版本更新

nwlls2ji  于 5个月前  发布在  其他
关注(0)|答案(2)|浏览(67)

所有人,
有一个看起来很天真的问题:我有一个在node 16中编译的应用程序(react/viteJS),我们在本地机器上使用mkcert在https上运行应用程序。应用程序运行得很好。现在是udpate部分。我们将我们的应用程序udpate到nodeJS版本20(和相应的包),我们一直得到这个

This site can’t be reached admin.localhost.com refused to connect.

字符串
在主机文件中,我们有以下

127.0.0.1       portal.localhost.com
127.0.0.1       admin.localhost.com

同样,切换到nodeJS 16时,这一切都可以工作。

a9wyjsp7

a9wyjsp71#

Node v20更喜欢ipv6而不是ipv4地址。您可以尝试将ipv6地址添加到hosts文件中:

::1       portal.localhost.com
::1       admin.localhost.com

字符串

svdrlsy4

svdrlsy42#

原来问题出在vite.js的配置上。出于某种原因,它特别需要将host设置为“localhost.com“,而令人惊讶的是,在node 16中没有这样做!

相关问题