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
3
Answers
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 .
CORS config on the S3 bucket should allow
OPTIONS
method for a preflight request.make sure OPTIONS returns 200 ok by running the curl command.
If not then run the below command
and dont forget to redeploy the API
for more details:
AWS API gateway error while making OPTIONS request