Android上的Ionic 2 CSP [英] Ionic 2 CSP on android

查看:65
本文介绍了Android上的Ionic 2 CSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序不显示相机图像,而是显示损坏的图像,但是对于其他图像(屏幕截图...),我不会遇到此问题。

My app does not display camera images, instead it shows broken image, but for other images (screenshots ...) I don't face this problem.

这是显示的错误:拒绝加载图像,因为它违反了以下内容安全策略指令: default-src *。请注意,未明确设置 img-src,因此将 default-src用作后备。

here is the error shown : Refused to load the image because it violates the following Content Security Policy directive: "default-src *". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback.

这种情况仅在相机图像上发生。

this happens only for the camera images.

有什么帮助吗?

推荐答案

您是否尝试过添加以下行:
<元http-equiv = Content-Security-Policy content = default-src *; style-src'self''unsafe-inline'; script-src'self''unsafe-inline ''unsafe-eval'> 到您的index.html?
另外,添加以下内容:
< allow-navigation href = * />
< allow-navigation href = file:// * / * />
<允许意图的href = * />
< access origin = * />

到您的config.xml,并告诉我它是否有效!
以防万一您尚未添加它,请添加cordova-plugin-whitelist插件!

编辑:还尝试添加另外三行:

Have you tried adding this line :
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> to your index.html?
Also, add the following :
<allow-navigation href="*"/>
<allow-navigation href="file://*/*" />
<allow-intent href="*"/>
<access origin="*"/>
to your config.xml, and tell me if it works!
And just in case you didn't add it already, add the cordova-plugin-whitelist plugin !
Edit : also try adding these three more lines :

<access origin="tel:*" launch-external="yes"/>
<allow-navigation href="https://*/*"/>
<allow-navigation href="data:*"/>

并删除您的< base href = /> 来自您的index.html。

and removing your <base href="/"> from your index.html.

这篇关于Android上的Ionic 2 CSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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