I am trying to make a call to my aws controlled (api-gateway) api.
$.ajax({
Type: "POST",
url: "<myURL>",
crossDomain: true,
data: <payload>,
contentType: "application/json",
success: function(data, status) {
data = JSON.stringify(data);
console.log(data);
if (status == "success") { <action> etc. }
API-Gateway is CORS enabled and has option & post integration response set up:
X-Requested-With '*'
Access-Control-Allow-Headers 'Content-Type,Authorization,X-Amz-Date,X-Api-Key,X-Amz-Security-Token'
Access-Control-Allow-Origin '*'
Access-Control-Allow-Methods 'POST,GET,OPTIONS'
I am sending from a S3 hosted static website and have the correct content-type. The same post works with postman as well as gets work. Why does the above one return the below?
OPTIONS 400:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https:/.io' is therefore not allowed access.