【问题标题】:How to handle `unsafe-eval` using bitbucket static sites如何使用 bitbucket 静态站点处理“不安全评估”
【发布时间】:2020-09-29 14:23:50
【问题描述】:

我使用 gatsby 编写了一个静态页面并进行了部署。 :80 没问题,当我将它托管在 github 静态页面上时,控制台也没有发送垃圾邮件错误。 对于我在项目中使用的每个<GatsbyImage/>,我的静态页面上都会出现这个 chrome-console-error。

[Report Only] Refused to connect to '<URL>' because it violates the following Content Security Policy directive:
"connect-src bitbucket.org *.bitbucket.org bb-inf.net *.bb-inf.net analytics.atlassian.com as.atlassian.com
api-private.stg.atlassian.com api-private.atlassian.com cofs.staging.public.atl-paas.net cofs.prod.public.atl-paas.net intake.opbeat.com api.media.atlassian.com api.segment.io
xid.statuspage.io xid.atlassian.com xid.sourcetreeapp.com bam.nr-data.net sentry.io bqlf8qjztdtr.statuspage.io <URL>".

谁能指出我 1. 理解问题 2. 正确处理它以避免所有这些控制台错误。我讨厌实时项目中的错误;-)

【问题讨论】:

    标签: bitbucket gatsby gatsby-image static-pages


    【解决方案1】:

    这是在 Gatsby 上使用 Content Security Policy 的问题。请参阅 [1] 的更多解释。 Gatsby 不能直接与 CSP 规则一起使用。

    为此,有一些插件,例如 [2] 中的一个插件,使得 CSP 规则部分由 Gatsby 生成。错误得到修复。

    来源:

    [1]https://github.com/gatsbyjs/gatsby/issues/10890

    [2]https://www.gatsbyjs.com/plugins/gatsby-plugin-csp/

    【讨论】:

    • 这也是我深入研究主题后得出的结论。感谢您提供相关答案。
    猜你喜欢
    • 1970-01-01
    • 2019-11-11
    • 1970-01-01
    • 2011-03-31
    • 2018-11-23
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多