Troubleshooting Cloudfront function not processing GET / request properly

Hey, I have a cloudfront distribution with an s3 origin, and a cloudfront function that is attached to viewer response, that modified some headers.
It works fine on GET <http://example.com/index.html|example.com/index.html>
But not on GET <http://example.com|example.com> - there’s not error, i just dont see the added headers.
the cloudfront function just add some headers, not conditions or something similar.

  const request = event.request;
  const response = event.response;
  const headers = response.headers;
  
  headers['custom-header'] = {value: 'value'};
  return response;
}```


Any idea why the function is not pre processing the `GET /` request ?

did you have website configuration on the s3 bucket before? did you set the default object to be index.html on requests to the bucket via the error response (404)? if so, cloudfront functions do not fire on 404s (or anything over 400). see: https://stackoverflow.com/questions/76354697/aws-cloudfront-with-s3-origin-cloudfront-function-viewer-response-not-invoked

resetting the default document was the solution, it was initially set… but removing and resetting it solve the issue