Reputation: 4483
I have created a lambda function which is to be accessed via an API Gateway. However whenever a post request is made I get the following error
When I navigate to was console and look at API Gateway I have
Finally my code (Angular2) does add the appropriate headers to the request by:
var headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
this.http.post('https://execute-api.us-east-1.amazonaws.com/prod/LambdaFunction', this.email, { headers: headers })
.subscribe(data => console.log(data),
err => console.log(err));
Any idea how to fix this?
Upvotes: 2
Views: 7673
Reputation: 346
Try this first
if this is not resolve from above use the below options as well. In my case if resolve by below steps.
Redeploy the API.
Upvotes: -2
Reputation: 424
I was getting same error and I fixed the issue following path:
Upvotes: 1
Reputation: 13025
Looks like you are beating the wrong bush.
You cannot enable CORS on a 403 since that is sent by APIGateway. The issue is you are trying to access a URL that is not accessible by APIGateway.
If your URL is correct and POST worked, you will still receive 200 OK on a CORS call, but you will not be able to access the content received. (That is browser standard to avoid CORS call without valid permission on the return headers)
Upvotes: 6