Почему сайт отказывается загружать шрифты?
Сайт написан на MERN стеке, проблема возникает при деплое на Heroku. В проекте используется Helmet
Ошибка:
Refused to load the font '<URL>' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
Refused to load the font 'https://fonts.gstatic.com/s/opensans/v18/mem8YaGs126MiZpBA-UFWJ0bbck.woff2' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
Я пытался гуглить, но ничего не помогло:
<meta http-equiv="Content-Security-Policy" content="font-src 'self' data: https://fonts.gstatic.com/ https://fonts.googleapis.com/; default-src 'self' https://fonts.gstatic.com/ https://fonts.googleapis.com/">
Настройка Helmet:
app.use(
helmet({
contentSecurityPolicy: {
directives: {
...helmet.contentSecurityPolicy.getDefaultDirectives(),
"img-src": ["'self'", "https:"],
"script-src": ["'self'", "https:"],
"font-src": ["'self'", "https:", " data:", "https://fonts.googleapis.com/", "https://fonts.gstatic.com/"],
"default-src": ["'self'", "https:", " data:", "https://fonts.googleapis.com/", "https://fonts.gstatic.com/"],
},
},
})
);