I am send post request from my web-page to AWS API Gateway which is invoking a lambda function. CORS is enabled in the API Gateway.
Error:
Failed to load api_gatewau_url: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'url' is therefore not allowed access.
The resource is having two methods:
- OPTIONS (integration MOCK)
- POST (integration Lambda)
How to solve CORS issue?
Below is the code for sending post request.
$.ajax({
type: "POST",
crossDomain: true,
url: "api_gateway_url",
data: JSON.stringify({
"param1": value1,
"param2": value2
}),
I have also tried to add headers with allow origin true etc but no luck.
Strangest thing, same configuration and request I am trying with different api gateway then it is working fine without any errors.