• Resolved Richard Bakos

    (@resonancedesigns)


    I have been banging my head against the wall on this for over a day now. First, let me break down the stack I am working with.

    System: Ubuntu 22.04
    Web Server: Apache
    Hosting: Linode

    The issue is that CORS is not working with AWS CloudFront. I have tried SO many things.

    I have all the mods enabled I need on apache (headers, ssl, etc)

    I have tried adding this to my /etc/apache2/apache2.conf file:

    <IfModule mod_headers.c>
        Header set Access-Control-Allow-Origin "*"
        Header set Access-Control-Allow-Methods "GET,POST,PUT,DELETE,OPTIONS"
        Header set Access-Control-Allow-Headers "Content-Type,Authorization,X-Requested-With"
        Header set Access-Control-Allow-Credentials "true"
    </IfModule>
    

    This is what my /etc/apache2/sites-available/libertyfitness247.com-le-ssl.conf file looks like:

    <IfModule mod_ssl.c>
            <VirtualHost *:443>
                    ServerAdmin [email protected]
                    ServerName libertyfitness247.com
                    ServerAlias www.libertyfitness247.com
                    DocumentRoot /var/www/html/libertyfitness247.com/public_html
    
                    ErrorLog /var/www/html/libertyfitness247.com/logs/error.log
                    CustomLog /var/www/html/libertyfitness247.com/logs/access.log combined
    
                    <Directory /var/www/html/libertyfitness247.com/public_html>
                            Options Indexes FollowSymLinks MultiViews
                            AllowOverride none
    
                            # WordPress
                            <IfModule mod_rewrite.c>
                                    RewriteEngine On
                                    RewriteBase /
                                    RewriteRule ^index\.php$ - [L]
                                    RewriteCond %{REQUEST_FILENAME} !-f
                                    RewriteCond %{REQUEST_FILENAME} !-d
                                    RewriteRule . /index.php [L]
                            </IfModule>
    
                    </Directory>
    
                    Include /etc/letsencrypt/options-ssl-apache.conf
                    SSLCertificateFile /etc/letsencrypt/live/libertyfitness247.com/fullchain.pem
                    SSLCertificateKeyFile /etc/letsencrypt/live/libertyfitness247.com/privkey.pem
            </VirtualHost>
    </IfModule>
    

    This is what my behaviour settings are in AWS:

    I have added the problem files, all of which are font files, to the “rejected files” settings in the plugin settings:

    I’ve run invalidations, cleared cache, etc, etc, etc…. Nothing seems to be able to fix this issue.

    I would be so appreciative for any assistance on this issue.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Richard Bakos

    (@resonancedesigns)

    Okay. I have fixed this issue. I feel it may have been an issue of the Cloudflare DNS. I cleared the cache on that and it works now. So I had to clear three caches, CloudFront, CloudFlare, and WordPress/Server. I removed the files from the “rejected files” setting in the plugin and did this cache clearing and it’s running fine, the problem files are being server by the CloudFront CDN without any CORS issues now. I hope this might help others in the future.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @resonancedesigns

    Thank you for reaching out.

    Thank you for providing the information about this. Yes, there are some issues with CORS headers and font files and it’s related to the CloudFront cors settings.
    And yes, multiple caching layers can cause problems like this because you cannot see the changes immediately.

    Once again, thank you for sharing this information as it will be very useful for other users that may encounter similar problems.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CORS Issues’ is closed to new replies.