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 Risposte
0
Risposta accettata

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

con risposta 2 anni fa
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
con risposta 2 anni fa
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.

con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande