Font from subdomain blocked by Cross-Origin resource sharing policy

I have the following error. The font from the source ' http://static.example.com ' was blocked from downloading under the Cross-Origin resource sharing policy: The requested resource does not have the "Access-Control-Allow-Origin" header. Origin ' http://www.example.com ' is therefore not allowed.

I use the following COR setting in the .htaccess file below

<IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" ExpiresByType text/cache-manifest "access plus 0 seconds" ........ <IfModule mod_headers.c> Header append Cache-Control "public" <FilesMatch "\.(ttf|otf|eot|woff|svg)$"> SetEnvIf Origin "^http://(.*)?example.com$" origin_is=$0 Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is </FilesMatch> <FilesMatch "\.(js|css|xml|gz)$"> Header append Vary: Accept-Encoding </FilesMatch> </IfModule> </IfModule> 

I need help with this

+7
cors wordpress .htaccess
source share
2 answers

Try in the .htaccess file:

 # Allow font assets to be used across domains and subdomains <FilesMatch "\.(ttf|otf|eot|woff|woff2)$"> <IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> 

You can learn more about this issue in this wonderful article I found: https://expressionengine.com/learn/cross-origin-resource-sharing-cors

+7
source share

Try adding this to your .htaccess file:

 Header add Access-Control-Allow-Origin "http://example.com" 

Alternative:

 Header add Access-Control-Allow-Origin "*" 
+1
source share

All Articles