Fixing CORS errors

Last Updated -


You might see an error similar to the message below on your site (when using your browser's developer tools):

Font from origin 'http://yourcdnurl.presscdn.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://www.yourdomain.com' is therefore not allowed access.

To fix the error, you just need to add the following to your site's wp-config.php:

header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");

Or you can try updating your .htaccess file to include the following rules to allow the webfonts/files to load:

# ----------------------------------------------------------------------
# CORS-enabled images (@crossorigin)
# ----------------------------------------------------------------------
<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    # mod_headers, y u no match by Content-Type?!
    <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
      SetEnvIf Origin ":" IS_CORS
      Header set Access-Control-Allow-Origin "*" env=IS_CORS
    </FilesMatch>
  </IfModule>
</IfModule>
# ----------------------------------------------------------------------
# Webfont access
# ----------------------------------------------------------------------
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

For more information, check out: Allow Webfonts using CDN

Note: If you are using Nginx-Only mode, add a file such as cors-nginx.conf within "/data/s*/dom*/user/nginx-server/" with the following:

location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
   add_header 'Access-Control-Allow-Origin' '*';
   add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}

Related Topics

  • Go Live
    When you are ready to make you site live (See pointing traffic to Pagely) on your actual domain, do the following. 1....

  • 2-Factor Authentication
    We have recently added 2FA to all Pagely Atomic accounts. [What is 2FA]  2FA adds another layer of security to your ...

  • Image Editors - using Imagick over GD
      What are Imagick and GD? Imagick and GD are popular Image optimization libraries in PHP applications. Are both Imag...

  • Your guide to Pagely's NGINX+Apache and NGINX-only modes
    Pagely supports two different webserver modes. The default mode is NGINX+Apache. There is another mode we refer to as...

  • EU Data Policies
    The following article is geared towards our VPS and higher plans. Shared sites and backups are hosted in our Virginia...

  • PHP 7 Server Rebuild FAQs
    The following FAQs cover some important details to be aware of when Pagely rebuilds your VPS in order to get PHP 7. P...

  • VPS Server Visitor Capacity and Temporary Resize FAQs
    How many concurrent users could we support on 1 site? This depends highly on the type of traffic and whether or not i...

  • EWWW Image Optimizer Plugin
    You may see the following error when using the EWWW plugin: EWWW Image Optimizer requires exec(). Your system adminis...

  • How send traffic through our UK DC
    Pagely has content cache nodes in Ireland.  To use them point your CNAME to global.pagelyhosting.com. This dns endpoi...

  • Fixing CORS errors
    You might see an error similar to the message below on your site (when using your browser's developer tools): Font fr...

Pagely is the Managed WordPress Hosting Platform designed to exceed the needs of media, business, and Enterprise customers alike. We help the world's biggest brands scale WordPress.

Copyright © 2006-2016 Pagely, Inc. All rights reserved.
Pagely® and WordPress® are registered trademarks.

Pagely
Powered by Zendesk