Ionic-cant在设备上发送http请求 [英] Ionic-cant send http requests on device

查看:216
本文介绍了Ionic-cant在设备上发送http请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找超过4个小时,但我找不到问题。
我正在构建一个带有离子的应用程序,当我用离子服务运行时,一切正常。

I have been looking around for more than 4 hours but I can't find the problem. I'm building an app with ionic and when I run it with ionic serve everything works.

当我尝试在我的Android设备(galaxy s3)上运行它时,我的每个请求都会保持返回状态0.

When I try to run it on my android device (galaxy s3) I keep getting return status 0 for every request I make.

我添加了白名单插件并添加了
< access origin =*/>
< allow-navigation href =*/ > 到我的config.xml

I have added the whitelist plugin and added the <access origin="*"/> <allow-navigation href="*"/> To my config.xml

在我的服务器上,我看到请求甚至没有达到,所以我不认为它是一个CORS问题。

On my server I see that the request is not even reaching so I dont think its a CORS problem.

我还添加了
< meta http-equiv =Content-Security-Policycontent =default-src * ; style-src'self''unsafe-inline'; script-src'self''unsafe-inline''unsafe-eval'>
到我的index.html但仍然所有看起来都一样。

i have also added <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> to my index.html but still all looks the same.

任何人都知道问题是什么?

Anyone know what the problem is?

BTW我正在使用 satellizer 作为外部包,它可以正常发送请求。

BTW I'm using satellizer as an external package and it sends the requests fine.

解决方案

您需要在 index.html中设置一些Content-Security-Policy元标记

< meta http-equiv =Content-Security-Policycontent =default-src'self'data:gap:https://ssl.gstatic.com; style-src'self''unsafe-inline'; media-src *>

您必须检查此插件,该插件控制可以导航WebView本身的哪些URL to:

and you have to check this plugin which Controls which URLs the WebView itself can be navigated to:

https:// github。 com / apache / cordova-plugin-whitelist

并在Cordova config.xml中尝试添加此行

and in the Cordova config.xml try to add this line

< access origin =*subdomains =true/>

这篇关于Ionic-cant在设备上发送http请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆