AWS API Gateway - CORS + POST not working

前端 未结 9 1821
一生所求
一生所求 2020-12-01 10:34

CORS is really driving me crazy and I\'m really out of ideas as of what to try to make it work.

I have created a simple APIG Api with 1 resource cal

9条回答
  •  情书的邮戳
    2020-12-01 11:04

    Here in 2020 and still finding other causes of the API Gateway CORS issues. For me (not using lambda proxy) I was still getting the CORS error even after using the API dropdown to enable CORS, and even after adding the 'Access-Control-Allow-Origin' header to the response from my Lambda function.

    What fixed it for me as adding the 'Access-Control-Allow-Origin' to the default Gateway Responses. Within the API Gateway UI, on the left-side menu, find Gateway Responses. Select 'Default 4XX' and edit it to include the 'Access-Control-Allow-Origin'. I set the value at '*' to be totally open during testing (including the quotes). Do the same for 'Default 5XX'. My ajax calls were able get passed the CORS error and now I see the real cause - the required parameters I set for the method weren't being passed in correctly.

    Yet, I don't know why did that present as a CORS error.

提交回复
热议问题