# Question: How to pass headers to lambda function?

**URL:** <https://forum.serverless.com/t/question-how-to-pass-headers-to-lambda-function/530>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [October 13, 2016, 5:51pm UTC](https://forum.serverless.com/t/question-how-to-pass-headers-to-lambda-function/530 "2016-10-13T17:51:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcio0](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/marcio0/32/208_2.png) [@marcio0](https://forum.serverless.com/u/marcio0)\
**Post date:** [October 13, 2016, 5:51pm UTC](https://forum.serverless.com/t/question-how-to-pass-headers-to-lambda-function/530/1 "2016-10-13T17:51:15Z")

</div>

I’m trying to duplicate an existing lambda function into a serverless app. I already got most of it right, but there is a configuration I can’t make.

I want to pass the `X-Forwaded-For` to the lambda function. I also have a request body template configured.

This is the function part on the serverless.yml:

```
functions:
  enpoint:
    memorySize: 128
    handler: handler.handler
    events:
      - http:
          method: POST
          path: reviews
          integration: lambda
          request:
            parameters:
              headers:
                'X-Forwarded-For': true
            passThrough: WHEN_NO_TEMPLATES
            template:
              application/json: '${file(json_mapping_template.txt)}'

          cors:
            origins:
              - '*'
            headers:
              - Content-Type
              - X-Amz-Date
              - Authorization
              - X-Api-Key
              - X-Amz-Security-Token

```

There was an issue with a similar problem: [#466](https://github.com/serverless/serverless/issues/466)

I looked into the `.serverless/cloudformation-template-update-stack.json` file and saw no reference to these settings.

On the AWS console, this setting is on the API Gateway, after selecting the POST method, Method Execution panel, HTTP Request Headers.

What am I doing wrong? If the question needs more info, let me know.

---

<div class="post-metadata">

**Author:** ![flomotlik](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/flomotlik/32/3_2.png) [@flomotlik](https://forum.serverless.com/u/flomotlik)\
**Post date:** [October 14, 2016, 2:24pm UTC](https://forum.serverless.com/t/question-how-to-pass-headers-to-lambda-function/530/2 "2016-10-14T14:24:23Z")

</div>

It should be passed through by default, can you add a console.log statement to the function to print the event data. You can also look into the proxy that would pass this through automatically: [https://serverless.com/framework/docs/providers/aws/events/apigateway/](https://serverless.com/framework/docs/providers/aws/events/apigateway/)

---

<div class="post-metadata">

**Author:** ![marcio0](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/marcio0/32/208_2.png) [@marcio0](https://forum.serverless.com/u/marcio0)\
**Post date:** [October 14, 2016, 2:41pm UTC](https://forum.serverless.com/t/question-how-to-pass-headers-to-lambda-function/530/3 "2016-10-14T14:41:00Z")

</div>

Hey, thanks!

It was really being passed by default. It was probably my misunderstading about how api gateway works.
