I get
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:
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?
Cross-Origin Resource Sharing (CORS) errors occur when a server doesn't return the HTTP headers required by the CORS standard. To resolve a CORS error from an API Gateway REST API or HTTP API, you must reconfigure the API to meet the CORS standard.
Cross-origin resource sharing (CORS) is a browser security feature that restricts HTTP requests that are initiated from scripts running in the browser. CORS is typically required to build web applications that access APIs hosted on a different domain or origin.
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
Create a new model from the left menu that you will call Empty and it works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With