Fail to enable CORS for API Gateway functions

0 votes

I get

enter image description here

While attempting to enable CORS on API Gateway, why is that and how do I resolve this? These functions are deployed using AWS SAM. But I notice if I create my own APIs via AWS Console this happens too

The errors looks like:

  • invalid model name specified application/json=Empty
  • invalid response status code specified

I found I seem to need to add an "Empty" response model myself?


Now, I get

Add Access-Control-Allow-Origin Integration Response Header Mapping to POST method (invalid response status code specified)

How do I resolve this?

Oct 9, 2018 in AWS by eatcodesleeprepeat
• 4,670 points
1,384 views

1 answer to this question.

0 votes

Firstly please select your root resource and select "Enable CORS". It will enable CORS to all methods. Ideally it should work. If in case it doesn't work Please add an empty json in the response as I have marked in the screenshot attached. I believe you don't have any default response header added in your OPTIONS method response (in Method Response ). Please refer screenshot

enter image description here

answered Oct 9, 2018 by Priyaj
• 56,920 points

Related Questions In AWS

0 votes
1 answer

How to Enable CORS for an AWS API Gateway Resource

Since you're using Lambda Proxy integration for ...READ MORE

answered Jul 10, 2018 in AWS by Hammer
• 360 points
812 views
0 votes
1 answer
0 votes
2 answers
+1 vote
3 answers

Not able to pass params POST to AWS Lambda from Amazon API Gateway

For this template : application/x-www-form-urlencoded  This line below will ...READ MORE

answered Jun 13, 2018 in AWS by Cloud gunner
• 4,280 points
2,381 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer