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

已提问 2 年前1516 查看次数
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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则