javascript - 从 localhost:xxxx 加载时的内容安全策略 ( style-src )
问题描述
我在控制台中的错误如下:
拒绝加载样式表 'data:text/css,@import%20url%28%27http%3A//localhost%3A8080/scorm/company1/scorm12/style/assessment.css%27%29%3B' 因为它违反了遵循内容安全策略指令:“style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://fonts.googleapis.com ”。
我在 http-header 中的 Content-Security-Policy 如下:
'Content-Security-Policy' "default-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com http://www.google-analytics.com 'unsafe-inline'; **style-src * 'unsafe-inline'** ;
问题是我用过style-src
,但为什么会发生错误我不知道。请帮助我并解释错误的详细信息。
最重要的是我现在在我的商业项目中使用这个策略。
所以我想快点。
解决方案
为什么要在 中使用双“通配符”(**)**style-src * 'unsafe-inline'**
?
它应该是"default-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com http://www.google-analytics.com 'unsafe-inline'; style-src * 'unsafe-inline'"
推荐阅读
- .net - 使用 C# 控制器将字符串返回到角度服务
- java - 如何使用 Hibernate 在单个实体中访问来自两个数据库的数据?
- php - 为什么 array_search 函数在被要求搜索未包含的值时返回 0 元素的键?
- html - 如何修复导航对齐并将图标添加到导航栏?
- string - Generate random string WITHOUT time?
- php - 将复杂查询从 Laravel 转换为 SQL
- java - 我可以将我在代码中编写的字符串中的数据存储在 SQlite 数据库中吗?
- python - Python 错误:行继续字符后出现意外字符。我该怎么办?
- azure-devops - 尝试将 webjob 添加到 Azure DevOps 发布管道
- google-apps-script - 使用 Google Apps 脚本修改 BigQuery 数据