Setting response headers only on documents

For anyone stumbling upon this thread in 2022, we can now fix this issue for ourselves using a Netlify Edge Function!

I wrote a blog post on this approach and included a code snippet that you can grab here: https://dev.to/philw_/using-a-netlify-edge-worker-to-cut-down-on-header-bloat-by-removing-html-only-headers-from-your-static-assets-3nh9

This should satisfy the webhint Unneeded HTTP Headers (no-html-only-headers) rule. I also added in the x-frame-options header too. Webhint doesn’t mention that one, but for me I don’t mind only applying it to HTML resources. Your mileage may vary, and I’m not a security expert by any means!

1 Like

Thank you for coming back and sharing this-- this will definitely be beneficial to future Forums members who encounter this obstacle.

Happy building :rocket:

1 Like