How to fix CORS issue?

  1. If your files are stored in the S3 bucket, make sure your domain is added in the AllowedOrigin or simply add this CORS configuration.

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "Access-Control-Allow-Origin"
        ],
        "MaxAgeSeconds": 3000
    }
]

To add this, login to your AWS console and navigate to S3 console and click to your bucket. Then, click on the Permissions tab and go to Cross-origin resource sharing (CORS).

  1. Otherwise, if you are using cloudfront or similar CDN, the CDN domain should at least a subdomain to your main site to avoid CORS issue.

  2. If the CORS error persists, contact your web administrator to add “Access-Control-Allow-Headers” header in the server configuration or allow “Access-Control-Allow-Headers” header in your application.

Last updated

Was this helpful?