2

我使用 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. 正确处理它以避免所有这些控制台错误。我讨厌现场项目中的错误;-)

4

1 回答 1

1

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

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

资源:

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

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

于 2020-10-08T16:23:46.880 回答