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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南