处理浏览器跨域访问本地http服务报错的问题

处理浏览器跨域访问本地http服务报错的问题:

报错详细内容:
The request client is not a secure context and the resource is in more-private address space local.

处理办法:

  • Edge浏览器
  1. 打开 Edge 浏览器,在地址栏输入 edge://flags/并按下回车键,进入浏览器的实验性功能设置页面。
  2. 在搜索框中输入 block-insecure-private-network-requests,然后找到该选项。
  3. 将该选项的状态从 “Default” 修改为 “Disabled”。
  4. 重新启动 Edge 浏览器。
  • Chrome浏览器
  1. 打开Chrome实验功能,在Chrome浏览器地址栏输入,chrome://flags/ ,访问。或者在地址栏输入:chrome://flags/#block-insecure-private-network-requests
  2. 找到 Block insecure private network requests.并且禁用

生成一个可以运行的程序或者批处理文件来自动设置浏览器的配置

创建一个批处理文件(.bat),将下面的代码粘贴到其中:

@echo off

echo Setting up Edge browser...
start msedge://flags/
timeout /t 5 /nobreak
echo Please navigate to the experimental features settings page.
timeout /t 5 /nobreak

echo Disabling block-insecure-private-network-requests...
reg add "HKCU\Software\Policies\Microsoft\Edge" /v BlockInsecurePrivateNetworkRequests /t REG_DWORD /d 0 /f

echo Restarting Edge browser...
start msedge://restart

echo Setting up Chrome browser...
start chrome://flags/
timeout /t 5 /nobreak
echo Please navigate to the experimental features settings page.
timeout /t 5 /nobreak

echo Disabling block-insecure-private-network-requests...
reg add "HKCU\Software\Policies\Google\Chrome" /v BlockInsecurePrivateNetworkRequests /t REG_DWORD /d 0 /f

echo Restarting Chrome browser...
start chrome://restart

echo Configuration complete.
pause

请注意,这个脚本需要管理员权限才能生效。运行后,它会依次打开 Edge 和 Chrome 的实验性功能设置页面,然后通过注册表编辑禁用 block-insecure-private-network-requests 选项,并最后重新启动浏览器。最后,脚本会显示 “Configuration complete.” 并等待用户按下任意键结束。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值