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

0

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.

Thanks

3개 답변
0
수락된 답변

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

답변함 2년 전
0

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.

RoB
답변함 2년 전
0

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.

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인