更新到 Edge 98.0.1108.43 后请求被 CORS 策略阻止:请求没有目标 IP 地址 space,但资源位于地址 space 私有

Request blocked by CORS policy after update to Edge 98.0.1108.43: Request had no target IP address space, yet the resource is in address space private

这个问题也发生在Chrome。

控制台错误:

Access to XMLHttpRequest at 'http://192.168.x.xxx:xxxx/' from origin 'http://xx.xxxx.com' has been blocked by CORS policy: Request had no target IP address space, yet the resource is in address space private.

My Edge 上个月运行良好。更新Edge后问题开始出现。

标志 #block-insecure-private-network-requests 已设置为禁用。

有谁知道如何在不将浏览器恢复到旧版本的情况下解决这个问题?

转到边缘 URL edge://flags/#block-insecure-private-network-requests

您可以从此处禁用或启用并重新启动浏览器。

所以对于edge,只需替换regedit路径

"Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome"

"Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge"

请注意,更改此设置将影响所有 urls。

更安全的方法是设置另一个注册表项,即 InsecurePrivateNetworkRequestsAllowedForUrls

步骤:

  1. 打开注册表编辑器
  2. 转到路径“Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\InsecurePrivateNetworkRequestsAllowedForUrls”(如果不存在则创建)
  3. add string(REG_SZ),key应该是整数,比如"1,2,3,...",每个字符串的值就是你要传递的url cors 政策

例如

SOFTWARE\Policies\Microsoft\Edge\InsecurePrivateNetworkRequestsAllowedForUrls = "http://www.example.com:8080"
SOFTWARE\Policies\Microsoft\Edge\InsecurePrivateNetworkRequestsAllowedForUrls = "[*.]example.edu"