Enable CORS to Resolve Web Font Issues
Sites deployed after June 23, 2019 will automatically have CORS enabled for webfonts. However, if you notice that font files aren’t loading correctly, or receive an error in the Browser Console about ‘Access-Control-Allow-Origin’ headers, then you need to modify your server config. The following steps will need to be performed with a Sudo User.
Start by connecting to the server using SSH and open the site’s static-files.conf
file:
sudo nano /etc/nginx/sites-available/{DOMAIN}/server/static-files.conf
Find the following location block:
# Cache WebFonts.
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 1y;
access_log off;
}
Then add the Access-Control-Allow-Origin
header, like so:
# Cache WebFonts.
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
expires 1y;
access_log off;
add_header Access-Control-Allow-Origin *;
}
Test that the configuration is correct using sudo nginx -t
. If everything looks good, reload Nginx:
sudo service nginx reload
Repeat for each site on the server which is experiencing CORS issues.