小编Neh*_*ngh的帖子

无法使用 Google 地图 API 实施严格的内容安全策略

对于maps.googleapis.com的common.js文件,我在chrome开发者工具的控制台中多次收到以下错误

common.js:15 
Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' https://fonts.googleapis.com https://s3.amazonaws.com https://maxcdn.bootstrapcdn.com". Either the 'unsafe-inline' keyword, a hash ('sha256-mmA4m52ZWPKWAzDvKQbF7Qhx9VHCZ2pcEdC0f9Xn/Po='), or a nonce ('nonce-...') is required to enable inline execution.
Run Code Online (Sandbox Code Playgroud)

我需要使用严格的 CSP 策略,因此不能使用 unsafe-inline 或 unsafe-eval 来放松策略。为了支持严格的 CSP 策略,不允许内联样式和脚本编写。似乎内联样式已在 google 地图 api 的 common.js 中使用,因此我收到上述错误。

有什么建议吗? 在此输入图像描述

security google-maps google-maps-api-3 inline-styles content-security-policy

5
推荐指数
1
解决办法
4046
查看次数