使用 apex 域名(CORS)下载字体失败

您好!我有一个 3.5.0.beta3-dev Discourse 实例,地址是 https://wingsoffire.forum。该实例设置在 www 子域名下,但我正在使用 Cloudflare CNAME 展平来使用根域名。

除了字体无法下载外,其他一切都按预期工作。使用 LibreWolf 137.0.1-1 时会显示此错误:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://wingsoffire.forum/fonts/Roboto-Bold.woff2?v=0.0.18. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘*, https://www.wingsoffire.forum, https://wingsoffire.forum’)。
downloadable font: download failed (font-family: "Roboto" style:normal weight:700 stretch:100 src index:0): bad URI or cross-site access not allowed source: https://www.wingsoffire.forum/fonts/Roboto-Bold.woff2?v=0.0.18

在标准的 Ungoogled Chromium 135.0.7049.84 上:

Access to font at 'https://wingsoffire.forum/fonts/Roboto-Bold.woff2?v=0.0.18' (redirected from 'https://www.wingsoffire.forum/fonts/Roboto-Bold.woff2?v=0.0.18') from origin 'https://wingsoffire.forum' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, https://www.wingsoffire.forum, https://wingsoffire.forum', but only one is allowed.
GET https://wingsoffire.forum/fonts/Roboto-Bold.woff2?v=0.0.18 net::ERR_FAILED 200 (OK)

当我访问您的网站时,我看不到特定的字体下载,但我确实看到一些资源是从 www.wingsoffire.forum 加载的,大部分是从 wingsoffire.forum 加载的。
从错误消息来看,此字体也在重定向。这可能会导致问题。

您应该

./launcher enter app

然后

discourse remap //www.wingsoffire.forum/ //wingsoffire.forum/
1 个赞

谢谢!

重写所有 //www.wingsoffire.forum/ 的实例为 //wingsoffire.forum/
将在 'default' 数据库上运行
此任务将重写数据,您确定吗 (输入 YES):YES

正在重新映射 default 上的表...

post_hotlinked_media=4
post_revisions=12
post_search_data=2
posts=126
site_settings=1
stylesheet_cache=825
topic_links=36
user_histories=10
完成

但是,即使在重启和重建之后也没有任何变化。仍然出现相同的错误。

这是管理面板中的字体选择菜单。

我可以在 https://wingsoffire.forum/fonts/Roboto-Regular.woff2?v=0.0.19 下载字体文件,但似乎它已损坏。

您能尝试清除 Cloudflare 缓存吗?

1 个赞

那解决了!谢谢你,我从来没想过。

复活节快乐!

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.