离子请求只有在Android返回404,Chrome浏览器正常工作离子、浏览器、正常、工作

2023-09-06 02:14:48 作者:揽风挽你

所以,我已经克隆出的离子教程应用程序回购。我跑

 离子开始会议sidemenu
 

,然后我添加了一个简单$ http.get('MYSERVER')(我试着用ngResources太)。

它完美的镀铬,我得到了所有的数据备份,但对角我只得到了空数据和任何要求404状态我试图做的。

请注意:我试着与我的托管服务器,并与本地的。在Android上都失败。 服务器是一个Node.js的REST API。

什么也没有打印在控制台上,所以请求甚至没有到达服务器。

有没有人经历过或能告诉我我该怎么调试建有离子Android应用?

编辑1:我不`吨知道为什么你需要它,但在这里它是

  $ http.get('http://server.com/route').success(功能(数据){
            //处理成功
        })错误(功能(数据,状态){
            //处理错误
        });
 
将Chrome浏览器模拟成安卓Android设备

解决方案

的事情是,有科尔多瓦4.0.0一些重大变化:

  

重大变化   [...]    - 白名单功能现在可以通过插件(CB-7747)提供的      白名单已得到增强,更安全和可配置      设置的内容安全性策略现在支持的框架      (见插件自述细节)你需要添加新的      科尔多瓦 - 插件白名单的插件遗产白名单的行为仍是      可通过插件(虽然不推荐)。

因此​​,我安装了科尔多瓦白名单的插件。并补充

 <允许导航HREF =HTTP:// * / */>
 

在我的的config.xml 文件。

So, i have cloned the tutorial app repo from ionic. I ran

ionic start conference sidemenu

and then i added a simple $http.get('myserver')(I tried with ngResources too).

It worked perfect on chrome, I got all the data back but on angular i only got null data and 404 status on any request I tried to do.

Note: I tried with my hosted server and with a local one. Both fail on Android. Server is a node.js REST API.

Nothing is printed on the console, so the request does not even get to the server.

Has anyone experienced that or could tell me how can I debug Android apps built with Ionic?

EDIT 1: I don`t know why do you need it but here it is

$http.get('http://server.com/route').success(function (data) {
            //handle success
        }).error(function (data, status) {
            // handle error
        });

解决方案

The thing is that there were some major changes in Cordova 4.0.0:

Major Changes [...] - Whitelist functionality is now provided via plugin (CB-7747) The whitelist has been enhanced to be more secure and configurable Setting of Content-Security-Policy is now supported by the framework (see details in plugin readme) You will need to add the new cordova-plugin-whitelist plugin Legacy whitelist behaviour is still available via plugin (although not recommended).

So I installed the Cordova Whitelist plugin. And added

<allow-navigation href="http://*/*" />

in my config.xml file.

 
精彩推荐
图片推荐