Solve problems with CORS in AWS
When trying to use the services from a different source through a browser we are getting CORS errors. The AWS API seems to have a setting for CORS which should set several things automatically: (https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html)
If you configure CORS for an API, API Gateway automatically sends a response to preflight OPTIONS requests, even if there isn't an OPTIONS route configured for your API. For a CORS request, API Gateway adds the configured CORS headers to the response from an integration.
But that doesn't seem to work, at least not when set through the AWS Management Console (web-UI). Therefore we must ourselves add handling of CORS into all the API Gateways (support an OPTIONS
method for preflight CORS requests) and the Lambda functions (handle the OPTIONS
requests and add the CORS headers).