Forward custom header from CloudFront to S3 website endpoint

Issue

This Content is from Stack Overflow. Question asked by Huy Vo

I have my S3 bucket configured as static website hosting. In the associated CloudFront distribution, I add a custom request header to be forwarded to my S3 website endpoint:
enter image description here

My expectation is that, when a request made to CloudFront and there is no cache found, CloudFront forwards the request to my S3 website endpoint with the custom header X-Origin-Verify. But in reality, my website endpoint doesn’t receive the custom header: I have redirected all requests coming to website endpoint to an API Gateway to check and found no X-Origin-Verify in requests’ header.

From the docs https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html#add-origin-custom-headers-configure, it seems adding custom header in “CloudFront > Distributions > Edit origin” would be enough, so I wonder why it does not work for me, or do I need to do something else?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?