Axios failing to downloand an image from s3 due to CORS

Viewed 1930

When making Axios GET call to retrieve an image from s3 bucket it creates a preflight check using OPTIONS method. Options method response includes the Access-Controll-Allow-Origin: * header with a wild card but the subsequent GET call fails to retrieve the image.

Browser console out put: Access to XMLHttpRequest at 'https://example.com' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Response headers from the OPTIONS call: Response headers from the OPTIONS call

Response headers from the subsequent GET call:

Response headers from the subsequent GET call:

Axios config for the GET call:

Axios config for the GET call:

1 Answers

Go to bucket permission and configure cors [https://docs.aws.amazon.com/AmazonS3/latest/userguide/ManageCorsUsing.html][s3 cors documentation]

enter image description here

Related