> ## Documentation Index
> Fetch the complete documentation index at: https://docs.manalens.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Security Policy (CSP)

> Allow the Web SDK in your site's Content Security Policy, and see the current CSP of the ManaLens dashboard.

## Overview

A Content Security Policy (CSP) tells the browser which scripts a page can run and where the page can send data. It is a defense against cross-site scripting (XSS): even if an attacker injects code, the browser blocks scripts and requests that the policy does not allow.

If your site sends a CSP, allow the SDK's script host and the collector endpoint.

## Allow the Web SDK

```html theme={null}
<meta http-equiv="Content-Security-Policy" content="
  default-src 'self';
  script-src 'self' https://cdn.jsdelivr.net;
  connect-src 'self' https://YOUR_COLLECTOR_ENDPOINT;
">
```

Put the tag in the `<head>` of your pages, or send the same policy as a `Content-Security-Policy` HTTP header.

| Directive | Allow | When you can use `'self'` alone |
| - | - | - |
| `script-src` | The host of the snippet `src` (`https://cdn.jsdelivr.net`) | You install from npm, or you serve the script from your own domain |
| `connect-src` | The collector endpoint | You send events through a [reverse proxy](https://docs.manalens.dev/guides/reverse-proxy.md) on your own domain |

## Combine with SRI

For the strongest protection, use CSP with [Subresource Integrity](https://docs.manalens.dev/security/sri.md):

* **SRI** makes sure the SDK file has not changed.
* **CSP** makes sure that only allowed scripts run, and that data goes only to the allowed endpoint.

## The dashboard's CSP

The ManaLens dashboard sends a strict policy with a new nonce for each request: scripts run only with that nonce (`'strict-dynamic'`), and the page cannot be framed (`frame-ancestors 'none'`), load plugins (`object-src 'none'`) or post forms to other sites.

> [!NOTE]
>
> The dashboard policy is in **Report-Only** mode today (`Content-Security-Policy-Report-Only`). The browser reports violations to us but does not block them yet. We will switch to enforcement after the reports show no false positives. These headers are enforced now: `X-Frame-Options: DENY` (no framing), `Strict-Transport-Security`, `X-Content-Type-Options: nosniff` and `Referrer-Policy: strict-origin-when-cross-origin`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.