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

lambda@edge origin-response handler with cloudfront + s3 origin custom headers


Hello, I've a function that works for origin-response.

I've added in my Cloudfront distro custom header, call it X-My-Header with a custom value (say a)

I want to read this custom header in the origin-response function (by using Typescript, shouldn't matter).

This header is no where to be found in either request.origin.s3.customHeaders nor request.origin.custom.customHeaders.

This is super difficult to debug. If someone has a suggestion or a direction I'll be extremely happy to hear.


3 Answers
Accepted Answer

Oh man, I was just missing creating a new invalidation :facepalm:

answered 9 months ago

Have you tried accessing the header via the event? For example below

const response = event.Records[0].cf.response;
const headers = response.headers;
console.log('Headers: "${headers}"');

If you still cant see them log the event and then view the json offline and confirm your header is actually present in the event.

answered 9 months ago

Thanks for the response, but no it's not that. I've created manually a function + λ distro and seems like it logs everything correctly in the freshly created one, in the origin-response invocation in request.origin.s3.customHeaders.

answered 9 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