1

I create lambda function:

exports.handler = (event, context, callback) => {
  const { response } = event.Records[0].cf;

  response.headers["x-my-header"] = [{ value: "test" }];

  return callback(null, response);
};

and I hit save and click on "test".

But I can't see the x-my-header. why? what I missing here?

1 Answer 1

1

I have run your LAmbda and received the following output when using the cloudfront-modify-response-header.

{
  "status": "200",
  "statusDescription": "OK",
  "headers": {
    "vary": [
      {
        "key": "Vary",
        "value": "*"
      }
    ],
    "last-modified": [
      {
        "key": "Last-Modified",
        "value": "2016-11-25"
      }
    ],
    "x-amz-meta-last-modified": [
      {
        "key": "X-Amz-Meta-Last-Modified",
        "value": "2016-01-01"
      }
    ],
    "x-my-header": [
      {
        "value": "test"
      }
    ]
  }
}

This looks like it is functioning correctly, I believe there is confusion for the difference between testing and the test event. The test event itself is the input for the Lambda function, when you test your function you would look at the output to see the response based on this event input such as in the screenshot below.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.