Serving custom headers from static sites on CloudFront/S3 with Lambda@Edge
Tom Cook

Hi Tom,

Thanks for the article. I have just tried this and a couple of notes:

  1. There is no longer specific edge nodejs runtime, but the lambda needs to be created in the N Virginia region and triggered by cloudfront.
  2. As pointed out in the other comment, I also used origin-response
  3. The code out of the box doesnt seem to work any more. It gives ERR_CONTENT_DECODING_FAILED. Solution is to use json syntax as follows:

headers[‘Strict-Transport-Security’] = [ { key: ‘Strict-Transport-Security’, value: “max-age=31536000; includeSubdomains; preload” } ];

headers[‘X-Content-Type-Options’] = [ { key: ‘X-Content-Type-Options’, value: “nosniff” } ];