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
asked a month ago138 views
1 Answer
1
Accepted Answer

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
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions