http-equiv Content-Security-Policy 在浏览器中有效,但在 Android 设备上无效 - IONIC

2024-05-04

我正在开发一个带有 ionic 的应用程序,刚刚插入了这个 Content-Security-Policy 元标记。

<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 设备上却出现很多错误。 我正在使用人行横道。

本地 chrome 中没有错误,但是当我使用 chrome://inspect 检查应用程序并在设备上运行它时,出现以下错误:

因此内容安全策略根本不适用于该设备。

我有什么错?


看来您需要一个显式 URI 方案,如下所述:

   内容安全策略错误,但元标记包含 URL https://stackoverflow.com/questions/31256348/content-security-policy-error-but-meta-tag-includes-url

因此,这样的事情应该有效:

<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">
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

http-equiv Content-Security-Policy 在浏览器中有效,但在 Android 设备上无效 - IONIC 的相关文章

随机推荐