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
preguntada hace 2 meses149 visualizaciones
1 Respuesta
1
Respuesta aceptada

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
EXPERTO
respondido hace 2 meses
profile picture
EXPERTO
revisado hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas