Software⏱️ 4 min read📅 2026-06-15

How to Fix: AWS S3 Bucket CORS Error

AWS S3 CORS configuration issue prevents image upload from webpage.

Quick Answer: The problem lies in the bucket policy, specifically the 'PublicListGet' statement. It allows only GET and LIST requests from any origin, but not POST requests. Update the policy to include POST requests for the specific resource ('arn:aws:s3:::cs-ia/*').

The CORS error occurs when the browser makes an XMLHttpRequest to a web server that is not from the same origin as the web page. In this case, the issue arises because the AWS S3 bucket's CORS configuration does not specify any specific allowed origins.

This error can be frustrating for developers who are trying to upload images from a webpage using the AWS S3 service. However, by following the steps outlined below, you should be able to resolve the issue and successfully upload your files.

💡 Why You Are Getting This Error

  • The primary reason for this error is that the CORS configuration of the S3 bucket does not specify any specific allowed origins. This means that the browser is unable to determine whether it can make requests to the S3 bucket from the current origin, resulting in a preflight request being sent with an empty 'Access-Control-Allow-Origin' header.
  • An alternative reason for this error could be due to the fact that the bucket policy does not explicitly allow GET requests. Although the policy allows s3:Get* actions, it only applies to the 'PublicListGet' statement, which is not applicable to all origins.

🛠️ Step-by-Step Verified Fixes

Enabling CORS on S3 Bucket

  1. Step 1: To fix this issue, you need to enable CORS on your S3 bucket. You can do this by going to the properties of your bucket and clicking on the 'Permissions' tab.
  2. Step 2: In the 'Permissions' tab, click on the 'CORS configuration' button and then add a new rule with the following settings: AllowedHeaders: *, AllowedMethods: PUT, POST, GET, HEAD, AllowedOrigins: *, ExposeHeaders: Access-Control-Allow-Origin. Click 'Save changes' to save your updates.
  3. Step 3: After enabling CORS on your S3 bucket, you should be able to make requests to the bucket from any origin without encountering a preflight request error.

Modifying Bucket Policy

  1. Step 1: As an alternative solution, you can modify your bucket policy to explicitly allow GET requests for all origins. You can do this by updating the 'Statement' section of your bucket policy.
  2. Step 2: Add a new statement with the following settings: Sid: AllowGetRequests, Effect: Allow, Principal: *, Action: s3:Get*, Resource: arn:aws:s3:::cs-ia/* Click 'Save changes' to save your updates.
  3. Step 3: After modifying your bucket policy, you should be able to make requests to your S3 bucket from any origin without encountering a preflight request error.

💡 Conclusion

By enabling CORS on your S3 bucket or modifying your bucket policy to allow GET requests for all origins, you should be able to resolve the CORS error and successfully upload your files. If you're still experiencing issues, please check that your CORS configuration is correctly set up and that there are no other restrictions preventing your requests from being made.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions