https://in.crispstats.com in two directives: script-src, so the browser loads d.js, and connect-src, so the script can send events to /e. Behind a first-party proxy, both requests go to your own domain and 'self' covers them. This page lists the entries for each setup and shows how to read the console error when something is still blocked.
Entries for each setup
connect-src covers every request the script makes after it loads: events sent with navigator.sendBeacon or fetch to /e, and the visitor id that crispstats.id() fetches from /id. Optional modules such as data-vitals and data-errors send to the same /e, so they need nothing more. With data-debug, nothing is sent at all.
The badge always fetches from https://in.crispstats.com, even when the script goes through a proxy.
Add the entries
Keep your existing sources and add the CrispStats origin to both directives. If your policy has noscript-src or connect-src, the browser uses default-src for them, so add the two directives explicitly.
/id and /check from a path on your own domain, 'self' is already enough:
data-api points to a full URL on another of your domains, such as https://stats.example.com, allow that origin in connect-src instead. crispstats.id() falls back to https://in.crispstats.com/id when the proxy does not answer with a visitor id; with a one-rule proxy it always answers, so 'self' is enough. On an older two-rule proxy, which forwards no /id, add https://in.crispstats.com to connect-src if you use crispstats.id().
To try a policy without breaking anything, send it as Content-Security-Policy-Report-Only first. The browser then reports what it would block in the console and still loads everything.
Inline code
Three snippets are inline<script> blocks rather than files:
- the queue stub that lets you call
crispstats()before the script loads (script attributes), - the Google Tag Manager tag, a Custom HTML tag that creates the script element,
- the live visitor badge.
'unsafe-inline' in script-src blocks them. Allow them the way you allow your other inline scripts, for example with a nonce that your server generates for each response:
src, so the origin entry is all it needs.
Read the console error
When the policy blocks a request, the browser logs an error in the console that names the URL and the directive. In Chrome, a blocked script looks like this:default-src, your policy has no specific directive for that request type: add script-src or connect-src as shown above.
Other headers
- Cross-origin isolation. The collector serves
d.jswithCross-Origin-Resource-Policy: cross-origin, so the script loads on pages that sendCross-Origin-Embedder-Policy: require-corp. - Subresource integrity. Do not add an
integrityattribute to the standard tag. The file athttps://in.crispstats.com/d.jskeeps its URL when the script is updated, so a fixed hash would stop matching and the browser would refuse the script. The same applies behind a proxy, which forwards the current file.
Next steps
Troubleshooting
Other reasons the script loads but nothing arrives.
Proxy
Serve the script and events from your own domain.
Script builds
d.js, d.core.js, caching and versions.