我有一个应用程序,用户可以在其中复制图像 URL,将其粘贴到输入中,然后图像将加载到框中。
但我的应用程序不断触发此消息:
拒绝加载图像“LOREM_IPSUM_URL”,因为它违反了以下内容安全策略指令:“img-src 'self' data:”。
这是我的元标记:
<meta http-equiv="Content-Security-Policy" content="default-src *;
img-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
style-src 'self' 'unsafe-inline' *">
我在应用程序中使用 html2Canvas,当我删除它时:“img-src 'self' data:”
它会引发此错误:
html2canvas.js:3025 Refused to load the image 'data:image/svg+xml,
<svg xmlns='http://www.w3.org/2000/svg'></svg>' 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.
以及一堆其他错误。
尝试更换这部分:
img-src * 'self' data: https:;
所以完整的标签:
<meta http-equiv="Content-Security-Policy" content="default-src *;
img-src * 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
style-src 'self' 'unsafe-inline' *">
内容安全策略参考 https://content-security-policy.com/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)