Spring server.address=localhost 无法从 Node.js 获取 api 连接

问题描述 投票:0回答:1

我已经解决了这个问题,但我还是不知道为什么。

当我设置“server.address=localhost”时,我有一个 Spring Boot 服务器,该服务器无法再从 Node.js fetch API 连接。但是使用网络浏览器是可以的,并且在主机文件中注释“::1 localhost”行时也可以。

这个问题的原因是什么?

node.js spring hosts
1个回答
0
投票

::1 localhost 是一种缩短本地主机 IPv6 地址的方法。 完整的字符串 IPv6,就像这样

xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
和这个
::1 localhost
的工作方式相同,因为它们是相同的。

我不建议禁用 IPv6 寻址,因为许多公共网络服务器现在默认使用它们。

编辑:您可能需要禁用 IPv6 来测试它。

© www.soinside.com 2019 - 2024. All rights reserved.