当我们试图用XHR (AngularJS $http call)从Windows10Cordova应用程序访问后端服务器时,我们遇到了一个问题。后端服务器是可用的(使用浏览器中的RESTclient插件进行测试)。该应用程序安装在Windows10桌面pc上,VisualStudio 2015支持(查看日志)。
下面是日志中的错误(法语中的“对不起”):
SCRIPT7002: XMLHttpRequest: Erreur réseau 0x2efd, Impossible d’effectuer l’opération à cause de l’erreur suivante 00002efd. 我们在index.html文件中添加了以下元标记(我们还尝试了通配符*):
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: http://10.148.118.68/* gap: http://10.148.118.68/* 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">下面是config.xml设置:
<access origin="*" />
<allow-navigation href="http://*/*" />
<allow-navigation href="https://*/*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" /> 关于信息,我们已经在Android设备上成功地构建和部署了应用程序,并且应用程序到达了后端。
谢谢你的帮助。
发布于 2017-02-01 07:38:10
使用cordova CLI创建的config.xml中的默认项目设置不包括PrivateNetwork XHR的功能。我们必须加上“手动”:
<Capabilities>
<Capability Name="privateNetworkClientServer" />
</Capabilities>发布于 2017-01-26 02:55:18
当我们试图用XHR (AngularJS $http call)从Windows10Cordova应用程序访问后端服务器时,我们遇到了一个问题。
这是设计上的,因为扩展不支持回送。请参考边缘扩展不能请求本地网。
https://stackoverflow.com/questions/41855713
复制相似问题