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 Respostas
0
Resposta aceita

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

respondido há 2 anos
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
respondido há 2 anos
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.

respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas