Content-Security-Policy header, the browser will block the ShieldLabs snippet unless you add its hosts to your allowlists. The snippet loads a module from a CDN, pulls in a dependency, and POSTs the collected signals to a few shieldlabs.ai endpoints. Each of those needs a directive.
If you have not added the snippet yet, start with Add the snippet and come back here once it loads.
Required directives
Add these two directives to your existing policy. Merge the hosts into directives you already have rather than duplicating them.What each host is for
script-src covers the code that runs. connect-src covers where the snippet sends data.
https://cdn.jsdelivr.net belongs in script-src because that dependency is fetched as a module, not in connect-src. The three shieldlabs.ai data endpoints belong in connect-src because the snippet connects to them to send data.The snippet uses no
eval and no new Function. It loads code by dynamic import() only, so 'unsafe-eval' is never required, even under a strict policy.Inline scripts: HTML method vs framework method
The two install methods from Add the snippet have different inline-script requirements.- HTML script tag (needs inline)
- Framework component (no inline)
The HTML method runs an inline Because the bootstrap code is inline, a policy that forbids inline scripts will block it. You have two options:
<script type="module"> that calls import():- Move the bootstrap into an external module file you serve from
'self'(no inline code), or - Use the framework component method instead (next tab), which has no inline script at all.
'unsafe-inline' if you can. The framework method removes the need for it entirely.Full-header examples
Drop these into your stack and adjust the surrounding directives to match your app. Only the two ShieldLabs directives are required.A very strict CSP can skip the local-network check
The snippet also runs a local-network check that feeds the Risk Score. A very strictconnect-src that blocks the local-network connection stops this one check from running.
This is acceptable degradation. The main snapshot still posts, identification still works, and the visitor is still scored. When the local-network check cannot run, it is recorded as “not checked”, which carries a small penalty, so the Score can shift slightly upward rather than down. It does not lower the Score. ShieldLabs only surfaces the anonymity signals and the Risk Score. Your own code still owns whether to allow, challenge, review, or block.
Verify it works
After deploying your policy:1
Load a page with the snippet
Open a page where the snippet runs and open your browser dev tools Console.
2
Check for CSP violations
A blocked host shows a
Refused to load or Refused to connect error naming the directive and the host. If you see one, add that host to the directive it names.3
Confirm the snapshot posted
In the Network tab, confirm a request to
rest.shieldlabs.ai succeeded. Once it does, the server scores the visit and delivers your webhook.Related
- Add the snippet: the HTML and framework install methods these directives support.
- API keys: the public key that goes in the snippet URL.
- Webhooks: where the score and signals arrive after the snapshot posts.