简体   繁体   English

白名单在 Ionic 中不起作用

[英]Whitelist not working in Ionic

The app gets json data from a php script on some server.该应用程序从某个服务器上的 php 脚本获取 json 数据。 it workes fine on my laptop, but does not work on the android phone.它在我的笔记本电脑上运行良好,但在 android 手机上不起作用。

I have this in my config.xml file我的 config.xml 文件中有这个

<access origin="*"/>
<allow-intent href="*"/>
<allow-navigation href="*"/>

It looks like the whitelist does not work.. What am i doing wrong?看起来白名单不起作用..我做错了什么?

Firstly remove whitelist plugin by cordova plugin remove cordova-plugin-whitelist , then install by cordova plugin add cordova-plugin-whitelist .首先通过cordova插件删除白名单插件删除cordova-plugin-whitelist ,然后通过cordova插件安装添加cordova-plugin-whitelist Finally, add these tag in your index.html file <meta http-equiv="Content-Security-Policy" content="default-src *; style-src &apos;self&apos; &apos;unsafe-inline&apos;; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos;">最后,在你的 index.html 文件中添加这些标签<meta http-equiv="Content-Security-Policy" content="default-src *; style-src &apos;self&apos; &apos;unsafe-inline&apos;; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos;">

A while ago cordova changed to a more restrictive whitelisting method.不久前,cordova 更改为更严格的白名单方法。 Since then you need to install cordova-plugin-whitelist to be able to access external resources.从那时起,您需要安装cordova-plugin-whitelist才能访问外部资源。

The fact that things are working on your labtop and not on the mobile points in this direction as well.事情在您的笔记本电脑上而不是在移动设备上运行的事实也指向这个方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM