Nginx - ошибка Access to font at from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Nginx - ошибка Access to font at from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Ошибка вида:
Access to font at 'https://site.ru/webfonts/fa-solid-900.ttf' from origin 'https://site.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
означает, что сайт site.com не может получить шрифты с другого сайта по ссылке https://site.ru/webfonts/fa-solid-900.ttf
А значит в конфиге nginx/apache не настроен CORS (cross-origin resource sharing) для шрифтов.
Ищем секцию для шрифтов и добавляем туда:
add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' '*';
Пример всей секции:
location ~* \.(eot|ttf|otf|woff|woff2|svg|svgz)$ { include proxy_params_common; include proxy_params_static; expires 60d; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' '*'; }
Пример для .htaccess Apache:
Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "*"
Про включение CORS на сервере: