AWS API Gateways CORS error

0

I am stuck with this error: 'Access to fetch at “https://xxxx’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: localhost/:1 Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.'

AWS
已提問 2 個月前檢視次數 149 次
1 個回答
1
已接受的答案

Hi,

As described on the AWS documentation, Cross-origin resource sharing (CORS) is a browser security feature that restricts cross-origin HTTP requests that are initiated from scripts running in the browser. In your case, from localhost to the API Gateway domain.

In order to fix it, your API response must include the Access-Control-Allow-Origin header, with the allowed domain name as value.

Thus, I recommend you take a look at the following Knowledge Center article, which described step by step how to troubleshoot the No ‘Access-Control-Allow-Origin’ header present CORS error, describing the possible causes as well as how to solve it for both HTTP and REST APIs.

profile picture
專家
已回答 2 個月前
profile picture
專家
已審閱 2 個月前

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

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

回答問題指南