I’ve created a Cloudflare proxy to point to the APIs deployed on AWS API Gateway.
I’ve followed all steps - generated certificate in Cloudflare, imported cert in AWS, created custom domain names, mapped APIs, created CNAME records, etc.
Connect Cloudflare to AWS API Gateway | Medium | Medium
Configuration is like:
- Cloudflare DNS name is api-test.mydomain.com.
- AWS API custom domain name url is like https://d-xxxxxx.execute-api.us-west-1.amazonaws.com
- AWS API invoke url in the deployed stage is https://yyyyyy.execute-api.us-west-1.amazonaws.com
In the Rules in Cloudflare, I added the rule - api-.mydomain.com/ to use strict SSL as recommended on one of the threads. (I’ve other APIs also on AWS API Gateway, like api-test2.mydomain.com, etc.)
When I’m testing the API using either Cloudflare DNS name or AWS API custom domain name url, I’m getting CORS error, like:
Access to XMLHttpRequest at ‘https://api-test.mydomain.com/api/v1/users?u=xyz’ from origin ‘https://mydomain.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.
The API call doesn’t even show up in the Cloudwatch logs.
When i’m testing with AWS API invoke url in the deployed stage, I’m able to get a response, and everything works fine.
Any help in resolving the CORS error is highly appreciated. Also, if any other information is required then please let me know.
Thanks in advance!