0

I need to set the CORS on website build on wordpress, and what I made:

I have added code to .htaccess and functions.php on my template as below. However, I the app with other domain still cannot load the fonts. I have even tested it with CORS tester, and there is information it should work perfectly. But it doesn`t...

The website is build on wordpress 5.3 and Elementor. Fonts are uploaded to Elementor.

I have even used another plugin for custom fonts, added @font-face css... and nothing... The errors about CORS still existing while checking console. Please, could anybody has any ideas how to fix it? I am getting mad about...

Thank you

Added to .htaccess

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

Added to functions.php

function add_cors_http_header(){
    header("Access-Control-Allow-Origin: *");
}
add_action('init','add_cors_http_header');
4
  • consider this answer: stackoverflow.com/questions/14467673/enable-cors-in-htaccess
    – Geoduck
    Commented May 11, 2022 at 20:22
  • thanks, but it also does not work. Server is Apache. Commented May 11, 2022 at 20:40
  • but you only set one of about 3 headers likely needed. Should at least set Access-Control-Allow-Method
    – Geoduck
    Commented May 11, 2022 at 20:50
  • thanks, but it still does not to work.... it seems Elementor is blocking icons and fonts... Commented May 12, 2022 at 7:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.