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.

Start Your 7-Day Free Trial

Start your SpinupWP journey today and spin up your first server within minutes.

Subscribe to get the latest news, updates and optimizations in performance and security.

Thanks for subscribing 👍

To receive awesome stuff, you'll need to head to your inbox and click on the verification link we sent you.
Make sure to check your "spam" folder or your "promotions" tab (if you have Gmail).
If you're still having trouble, then message us at sudo@spinupwp.com.

You are already logged in

It looks like you are already logged in to SpinupWP.

Please log out of this account to continue.

Registration Successful

Thanks for registering for a new
SpinupWP account.

Before getting started, could you verify your email address by clicking on the link we just emailed to you?

SpinupWP

Free Trial

Start Your 7-Day Free Trial

No credit card required. All features included.

By signing up to SpinupWP, you agree to our Terms and Conditions.
For privacy related information, view our Privacy Policy.