Serverless setting to which allows Apigateway to forward custom header to AWS Lambda

What is a simple example of the portion of the serverless.yml which would allow the APIGateway to pass through a custom request header to my AWS Lambda. Basically if header[‘Foo’] was included in the API Gateway request, how to get that header, as-is, to the AWS Lambda function?

If you’re using Lambda proxy integration then event.headers should be an object with all of the headers passed to the API Gateway.

Thank you for a quick response. I see that you are correct: all my headers did get passed by the API gateway. Their names were not in the same case as they were sent.

I seem to remember having the same problem a while ago. I solved it by writing a simple function to copy the header object but lower case all of the keys.

New instances of API Gateway use HTTP/2, which automatically converts all headers to lowercase per the spec.

1 Like