By using AWS re:Post, you agree to the Terms of Use

Is it possible to pass headers in Nodejs Lambda API



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 ?

1 Answer

Please take a look at this troubleshooting guide to see if any of these reasons are responsible -

Have you configured CORS on your API Gateway API?

profile picture
answered 3 months 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