小编Pja*_*yno的帖子

(CSP) 内容安全策略。处理从外部库添加的内联样式的方法

有没有办法处理从外部库添加的内联脚本/样式?在我自己的风格中,我只使用随机数,但无法将其添加到外部库。

我使用 tooltip.io,当库尝试运行时出现问题:

function() {
                var n = e("./styles/css/styles.scss")
                  , t = document.createElement("style");
                t.innerHTML = n,
                document.head.appendChild(t)
            }(),
Run Code Online (Sandbox Code Playgroud)

CSP展示

[Report Only] Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-b123d558a63bc7e84aa7' ". Either the 'unsafe-inline' keyword, a hash ('sha256-SamqqFx+xVKq8AnoIWgeammNlDl/h4AP94HthfQO43Q='), or a nonce ('nonce-...') is required to enable inline execution.
Run Code Online (Sandbox Code Playgroud)

有什么方法可以处理此类错误吗?

javascript content-security-policy

7
推荐指数
1
解决办法
4874
查看次数