AWS - S3 - CORS
CORS is a feature of HTTP that uses headers to allow
browsers to display content that a web server requested from a different
origin.
To allow your content to appear, configure a CORS policy on your Amazon S3 bucket.
Proper configuration of the CORS policy makes
sure that the appropriate headers are returned.
You can configure a CORS rule on your bucket using the Amazon
S3 console or AWS CLI.
Cross-origin resource sharing (CORS) defines a way for client
web applications that are loaded in one domain to interact with resources in a
different domain.
To configure your bucket to allow cross-origin requests, you
add a CORS configuration to the bucket.
A CORS configuration is a document that defines rules that
identify the origins that you will allow to access your bucket, the operations
(HTTP methods) supported for each origin, and other operation-specific
information.
I am starting with creating an S3 bucket and setting up a static website.
Now, the bucket has CORS setup and it allows GET and HEAD calls from the Allowed Origins which is the same as the bucket endpoint (Static Page). You can configure Allowed Origin as any domain name. It refers to which DOMAIN name the website can be accessed. To test CORS, I created a EC2 instance and doing a CURL with the below headers: For example, if you make a request to http://www.rsinfominds.com/ in Chrome, the request header contains Origin:http://www.rsinfominds.com (the browser automatically sends this), and the response header from the server contains Access-Control-Allow-Origin:http://www.rsinfominds.com.
When I change the Origin to "http://rsinfominds.com" in the curl it works.
Comments
Post a Comment