Skip to main content
Headers
Matt Gray avatar
Written by Matt Gray
Updated over a year ago

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.
​

  1. Visit your staging, development and production headers pages.

  2. In the table, add your headers. They are formed from three elements:
    ​

    1. 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.

    2. Header Key: the key of the header e.g. `X-Frame-Options`

    3. Header Value: the value of the header e.g. `SAMEORIGIN`

  3. Click the "Add Another" button to add more rows for additional headers.

  4. Click the "Save" button.

  5. 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" %}
Did this answer your question?