Hi I am trying to hit a AWS API gateway it's working fine on CURL but not working from JS Brocking for CROS policy. But from AWS I already enabled CROS
$.ajax({
url: ApiURL,
type: 'POST',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(hash),
async: true,
crossDomain: true,
crossOrigin: false,
headers: {
'accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'POST'
},
CURL method hit through AJAX
$.ajax({
url: stripTrailingSlash(BASE_URL) + '/contact/send',
type: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(body),
async: true,
headers: {
'X-CSRF-Token': csrfToken
},
My api gateway POST structure like this
My lambda response I did like this
const response = {
statusCode: statusCode,
headers:{ 'Access-Control-Allow-Origin' : '*' },
body: JSON.stringify({
message: responceMessage,
input: event,
}),
};
callback(null, response);
Error I am getting in my browser