amazon-web-servicesamazon-s3axiosaws-api-gateway

PUT call not working for s3 bucket using a AWS GATEWAY api?


admin:1 Access to XMLHttpRequest at '/dev/directjobfinder/listing.json' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

IT'S WORKING FINE IN POSTMAN BUT WHEN IM USING AXIOS.PUT THEN IT'S GIVING THE ABOVE ERROR SOMEONE PLEASE HELP I'M STUCKED FROM LAST 2 DAYS

I HAVE DONE Access-Control-Allow-Headers : * Access-Control-Allow-Origin : *'

CORS CONFIG file of S3 bucket [ { "AllowedHeaders": [ "*" ], "AllowedMethods": [ "GET", "PUT" ], "AllowedOrigins": [ "*" ], "ExposeHeaders": [] } ]

EDIT : ERROR DETAILS SCREENSHOT


Solution

  • ANSWER : I was calling the api using axios and my method was POST but the problem was in the response header , I was passing a javascript object as application/json , there resides the problem itself i just change it to tex/plain then it works fine .