问题描述
我正在开发一个应用程序与离子,只是插入此Content-Security-Policy元标记。
I'm developing an app with ionic and just inserted this Content-Security-Policy meta-tag.
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' fonts.googleapis.com 'unsafe-inline'; script-src 'self' code.jquery.com cdn.firebase.com www.gstatic.com maps.googleapis.com localhost:35729 apis.google.com 'unsafe-inline' 'unsafe-eval' https://domain.com">
我没有在浏览器中遇到任何错误,但在Android设备上。
我使用的是crosswalk。
I don't get any errors in the browser but alot on the android device.I'm using crosswalk.
Chrome本地没有错误,但是当我使用chrome://检查应用程序时,检查并运行它在设备上这些错误:
No errors in chrome locally but when i inspect the app with chrome://inspect and run it on the device I get these errors:
所以内容安全策略不工作在设备上。
So the Content-Security-Policy isn't working on the device at all.
我的错误是什么?
推荐答案
您似乎需要一个显式的URI方案,如下所述:
It appears you need an explicit URI scheme as described here:
content security policy error, but meta-tag includes URL
因此,这样的操作应该可以工作:
Thus, something like this should work:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' https://fonts.googleapis.com 'unsafe-inline'; script-src 'self' https://code.jquery.com https://cdn.firebase.com https://www.gstatic.com https://maps.googleapis.com localhost:35729 https://apis.google.com 'unsafe-inline' 'unsafe-eval' https://domain.com">
这篇关于http-equiv Content-Security-Policy在浏览器中工作,但不在Android设备上 - IONIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!