AWS S3 Bucket CORS Setting - mymagic/open_hub GitHub Wiki

Cross-Origin Resource Sharing for AWS S3 Bucket

Introduction

For modules that request for resources from AWS S3 Bucket to be displayed on the browser, modern browsers checks the response header for origin. If the origin is not listed in the header, the browser will reject the request and this can be seen as CORS error in the developer tool of your favourite browser.

TLDR

To allow your browser to be able to display resources in your S3 Bucket, you need to enable the CORS settings in your AWS S3 Bucket.

In this example, we are using hub.example.com, hubd.example.com and central.example.com

{

    "AllowedHeaders": [
        "*"
    ],
    "AllowedMethods": [
        "GET"
    ],
    "AllowedOrigins": [
        "https://hub.example.com", # your staging env
        "https://hubd.example.com", # your development env
        "https://central.example.com" # your production env
    ],
    "ExposeHeaders": []

}

I need step by step instruction


  1. Login to your AWS Account at aws.amazon.com.
  1. Go to your S3 Bucket.

step 1

  1. Select bucket you store

step 2

  1. Go To Permission

step 3

  1. Edit CORS

step 4

  1. Insert CORS Configuration and Save

step 5

AWS Documentation