I have built the API below but am getting CORS errors in Chrome's network debugger. Opaque responses do not work in parsing the dta
curl -v -X OPTIONS https://pegu8bngmb.execute-api.us-east-1.amazonaws.com/prod/
I have some JavaScript below, the POST method works, but the GET method is getting CORS errors. I have built the API using AWS API Gateway, and enabled CORS.
fetch("https://101wvh4x70.execute-api.us-east-1.amazonaws.com/dev", {
method: "GET",
// mode: "no-cors",
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,OPTIONS,POST",
"Content-Type": "application/json"
},
})
.then(function(response) {
console.log(response)
})
.catch(function(err) {
console.log('error')
});
"Access-Control-Allow-Headers":["Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token"],"Access-Control-Allow-Methods":["GET,OPTIONS,POST"],"Access-Control-Allow-Origin":["*"]
// POST Method
fetch("https://pegu8bngmb.execute-api.us-east-1.amazonaws.com/prod/", {
method: "POST",
mode: "no-cors",
body: JSON.stringify({
"record_id": {
"S": "0"
},
"record_count": {
"N": "11"
}
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
});