Ionic 2 CSP on android

馋奶兔 提交于 2019-12-11 09:29:27

问题


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

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.

any help ?


回答1:


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:*"/>

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



来源:https://stackoverflow.com/questions/42788573/ionic-2-csp-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!