Add cloudfront compatibility and move header to a separate file