使用 cordova 和 Ionic 构建的 UWP 不考虑主机文件

UWP built with cordova and Ionic don't take hosts file into account

我正在使用 cordova 和 Ionic 为 Windows UWP 构建应用程序。 当我 运行 这个代码

this.http.post('htpp://myDomain.com/path/', data).toPromise().then(() => { ... });

它进入 catch 子句返回状态为 0 的响应。

我也收到这个警告,不知道是否相关:

CONSOLE21301: serviceWorker.getRegistrations is rejected due to unsecure context or host restriction in ms-appx-web://microsoft.microsoftedge/assets/errorpages/dnserror.html?ErrorStatus=0x800C0005

我的主机文件

127.0.0.1       localhost myDomain.com

有人有办法解决这个问题吗?

提前致谢

终于找到了!

运行使用此命令允许 uwp 应用程序 运行 向本地服务器发出请求!

CheckNetIsolation.exe LoopbackExempt -a -n="[app PackageFullName]"