Report this

What is the reason for this report?

How do I add custom HTTP headers to a hosted static site?

Posted on January 1, 2021

Connected Tutorial(This question is a follow-up to this tutorial):

How To Deploy a Static Website to the Cloud with DigitalOcean App Platform

How do I setup Digital Ocean’s static sites with custom headers, like “Referrer-Policy”?

Netlify let’s you set custom headers for static sites by adding to their TOML file:

[[headers]]
  for = "/*"
  [headers.values]
    Referrer-Policy = "no-referrer"
    X-Content-Type-Options = "nosniff"
    X-Frame-Options = "deny"
    X-XSS-Protection = "1; mode=block"

What’s the equivalent for an app spec on Digital Ocean?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks for the question. This functionality isn’t currently available for static sites components in the App Platform. We’ll consider this as a feature. Service type components can set any headers as they respond to requests.

Is there no way to modify headers for a static site on your platform?

We need to modify Content-Security-Policy settings to pass a required security review. Any insights would be appreciated.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.