Bypass CORS policy on S3-hosted site connected to RDS database

0

I have a public domain in S3 connected to an RDS database via MySQL, a lambda function that runs scripts on the MySQL database, and an API gateway that sends queries to the lambda function. Whenever I try to make an API call from my site, I get the error below.

Access to XMLHttpRequest at (lambda url) from origin (my site) has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

How can I get around this?

1 回答
1

You can activate CORS on the API-Gateway. https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html
This will add the required OPTIONS Method for the preflight Request to your API.

AWS
Marco
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则