Is it possible to pass headers in Nodejs Lambda API

0

Hi,

I have created a Nodejs Lambda, which require header parameters. Lambda deployed by the 'serverless.yml' file and corresponding API Gateway created for all APIs with lambda proxy integration. When I execute those APIs with headers parameters it throws CORS error like this,

Request header field 'abc' is not allowed by Access-Control-Allow-Headers in preflight response

I have given 'Allow Headers' in entry component.

app.use(function (req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT,DELETE"); res.header("Access-Control-Allow-Headers", "Content-Type"); next(); });

Is there any solution to pass headers ?

preguntada hace 2 años1494 visualizaciones
1 Respuesta
1

Please take a look at this troubleshooting guide to see if any of these reasons are responsible - https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cors-errors/

Have you configured CORS on your API Gateway API?

profile pictureAWS
EXPERTO
respondido hace 2 años
profile picture
EXPERTO
revisado hace 8 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