• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Wordpress themes files to another domain like CDN

ezramod

New member
Nov 9, 2020
21
2
3
Hi, is it possible to load static files (theme) on a domain and add them to LScache in CDN?

I try to do this but firs appear:
Access to font at 'https://seconddomain.com/wp-content/themes/v2/assets/fontawesome/webfonts/fa-brands-400.woff2' from origin 'https://domain_one.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.


after i add in .htaccess

<ifmodule mod_headers.c="">
SetEnvIf Origin "^(.*\.seconddomain\.com)$" ORIGIN_SUB_DOMAIN=$1
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
Header set Access-Control-Allow-Methods: "*"
Header set Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept, Authorization"
</ifmodule>

appear this:

(index):9 GET https://seconddomain.com/wp-content/themes/v2/assets/fontawesome/css/all.css net::ERR_ABORTED 404 - But if i access url files in browser works

second try was to add CNAME in domain one: cdn.domain_one.com to seconddomain.com and receive same error:

(index):9 GET https://cdn.domain_one.com/wp-content/themes/v2/assets/fontawesome/css/all.css net::ERR_ABORTED 404 - But if i access url files in browser works

have something ideea about this ?
 
Last edited:
Hi

This is because web fonts are subject to Cross-Origin Resource Sharing (CORS). CORS is a way for a remote host to control access to certain types of resources.

To resolve this issue you need to ensure that your server is sending the correct Access-Control-Allow-Origin header when font files are requested. If you’re unable to modify your server configuration please contact your web host and tell them :

For Apache

<FilesMatch ".(eot|otf|ttf|woff|woff2)">
Header always set Access-Control-Allow-Origin "*"
</FilesMatch>


for nginx

location ~* \.(eot|otf|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}


also you may need to add “/*” to your CDN distribution.
 
  • Like
Reactions: nesym
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock