I have two CloudFront Distributions:
- one uses S3 as Origin - route53 Domain - example.com
- second uses API Gateway URL as Origin. - route53 Domain - api.com
JS Code is hosted on S3 and First Cloudfront Distribution.
https://example.com/test.html
is giving call to https://api.com/api?<queryParameters>
However I am getting error saying:
Access to XMLHttpRequest at 'https://api.com/api?<queryParameters>' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I tried adding Access-Control-Request-Headers
,Access-Control-Request-Method
and Origin
in Whitelist of Cache Based on Selected Request Headers
in API CloudFront Behavior. Still no luck