Access to font at ‘https://localhost/… from origin has been blocked by CORS policy

This topic has 2 replies, 2 voices, and was last updated 1 months, 1 weeks ago ago by Rose Tyler

  • Avatar: jp110
    jp110
    Participant
    February 22, 2025 at 20:03

    Your theme is too good to be true!

    I developed my website on localhost and then moved it to live server.
    I’m getting error on every page for the font RethinkSans-Regular.ttf:

    https://localhost/–website–/wp-content/uploads/custom-fonts/2025/01/RethinkSans-Regular.ttf net::ERR_FAILED 200 (OK)

    Access to font at ‘https://localhost/–website–/wp-content/uploads/custom-fonts/2025/01/RethinkSans-Regular.ttf’ from origin ‘https://www.–website–.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

    I have given the correct permissions for the uploads folder.
    Moreover, I have changed the default font to Opens Sans in my entire site, but still getting this error.

    Please assist.
    Regards,
    JP

    1 Answer
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    February 24, 2025 at 08:40

    Hello,

    Thank you for getting in touch with us.

    Regarding the issue you are facing, it appears that the font file is still being referenced from your localhost environment, which is causing a CORS (Cross-Origin Resource Sharing) policy restriction when accessed from your live website. Here are a few steps to resolve this issue:

    1. Clear Cache: Ensure that your website cache, as well as your browser cache, is cleared. Sometimes, old references remain cached even after changes are made.

    2. Check Font References: Verify that all font references in your theme settings, custom CSS, and database are correctly pointing to the live server instead of localhost. You may need to search your database for any remaining localhost URLs and update them accordingly.

    3. Update CORS Policy: If the font file is correctly uploaded to your live server but still being blocked, you may need to allow cross-origin access. You can do this by adding the following rule to your .htaccess file (if using Apache) or configuring the appropriate settings in your server:

    apache
    
    Header set Access-Control-Allow-Origin "*"
    
    

    If you are using Nginx, you can add this to your configuration:

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

    Or contact your hosting provider and ask to do this.
    4. Verify Font Settings: Since you have changed the default font to Open Sans, ensure that no custom font settings are still referencing “RethinkSans-Regular.ttf” in your theme options, custom CSS, or any third-party plugins, like Elementor plugin settings.

    5. Regenerate Font Files: If the issue persists, try re-uploading the font files to the correct directory on your live server and ensure they are accessible via direct URL.

    If you continue to experience difficulties, read this article – https://crunchify.com/how-to-fix-access-control-allow-origin-issue-for-your-https-enabled-wordpress-site-and-maxcdn/ and contact your hosting provider to get further assistance.
    The current situation is independent of our theme.

    Warm Regards,
    The 8Theme Team

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

Helpful Topics

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.