HTTP headers are the meta-data that is returned alongside the request responses from your project. On Servd, there are a few ways to configure them:
Via the Servd Dashboard
You can configure the headers returned by your project environments via the Servd dashboard.
β
Headers are configured on a per-environment basis, allowing you to test specific configurations in staging before copying those same settings over to production.
β
Visit your staging, development and production headers pages.
In the table, add your headers. They are formed from three elements:
βFrom Path: a pattern which is checked against the incoming URL path (the part after the domain, excluding query params). If this pattern matches the header is added.
Header Key: the key of the header e.g. `X-Frame-Options`
Header Value: the value of the header e.g. `SAMEORIGIN`
Click the "Add Another" button to add more rows for additional headers.
Click the "Save" button.
Sync your project.
The From Path pattern is evaluated as regex. The full scope of regex is too large to discuss here, but you can learn more here and try some examples here.
Via Twig
It's also possible to add headers in your templates via Craft's `header` twig tag, which looks something like:
{% header "X-Frame-Options: SAMEORIGIN" %}