cjk77
(Chris Klugewicz)
25 Aprile 2020, 11:48pm
1
Sto cercando di utilizzare un font speciale in uno dei componenti del mio tema. Ho seguito le istruzioni in questo post:
Themes and theme components allow you to handle uploaded assets such as images and fonts. You can control what assets your theme accepts using the site setting: theme authorized extensions
Including assets in themes and components
For remote themes
Remote themes include:
Themes and components installed from the Popular list of themes
Themes and components installed using the From a git repository method
To upload assets to a remote theme or theme component, see Create and share a font theme …
Ecco il CSS del mio componente:
@font-face {
font-family: 'northwood';
font-style: regular;
src: url($northwoodhigh) format('woff2');
}
.category-list tbody .category h3 a[href] {
color: #ccc;
font-family: 'northwood', cursive;
font-size: 135%;
word-spacing: 3px;
}
Ho aggiunto l’URL di Cloudfront alle impostazioni CORS in questo modo:
Ma non funziona: purtroppo, quando carico una pagina con quel CSS, ottengo un errore “Cross-origin request blocked” nella console:
(Scusa per l’immagine molto piccola.) Qualcuno ha qualche consiglio? Sono bloccato.
Do you have the DISCOURSE_ENABLE_CORS in your app.yml as suggests the description?
1 Mi Piace
cjk77
(Chris Klugewicz)
26 Aprile 2020, 11:30am
4
Not sure – is there a way to check? (I’m on a hosted instance of Discourse, so I can’t look at the config files directly.)
Edit: I emailed our hosting provider to see if that’s the problem.
cjk77
(Chris Klugewicz)
26 Aprile 2020, 3:33pm
5
Update: my hosting provider confirms that DISCOURSE_ENABLE_CORS is set to TRUE.
So, I’m still baffled.
Johani
(Joe)
28 Aprile 2020, 1:51am
7
I just tried this, just like you described, on a site with a CDN setup and it worked. So, I think this might be limited to your site.
I think the DISCOURSE_ENABLE_CORS setting is the inverse of what you want. Adding domains to that setting will allow requests from those domains access to your Discourse domain, not the other way around.
What you want is to allow requests from your Discourse domain to get access to the file on your CDN. I think your CDN is blocking those requests. You can confirm that by running something like this in a terminal window, after you change the values of course.
curl -H "origin: YOUR_SITE_URL" -v "PATH_TO_THE_FONT_ON_YOUR_CDN"
If everything is setup correctly, you should see something like this in the response headers
Access-Control-Allow-Origin: *
2 Mi Piace