Font download fails using apex domain (CORS)

Hello! I have a 3.5.0.beta3-dev Discourse instance at https://wingsoffire.forum. The instance is set up under the www subdomain, but I am using Cloudflare CNAME flattening to use the apex domain.

Everything works as expected except that fonts cannot be downloaded. This error is shown using 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

And on stock 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)

I don’t see the specific font download when I visit your site, but I do see some resources being loaded from www.wingsoffire.forum and most from wingsoffire.forum.
This font is also redirecting looking at the error message. That might cause the issue.

You should

./launcher enter app

then

discourse remap //www.wingsoffire.forum/ //wingsoffire.forum/
1 Like

Thanks!

Rewriting all occurrences of //www.wingsoffire.forum/ to //wingsoffire.forum/
WILL RUN ON 'default' DB
THIS TASK WILL REWRITE DATA, ARE YOU SURE (type YES): YES

Remapping tables on 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
Done

However, there is no change, even after a restart and rebuild. The same errors are given.

Here is the font selection menu in the admin panel.

I can download the font file at https://wingsoffire.forum/fonts/Roboto-Regular.woff2?v=0.0.19, but it seems like it’s broken.

Can you try to purge the Cloudflare cache?

1 Like

That fixed it! Thank you, I would never have thought of that.

Happy Easter as well!

1 Like