How to Configure a Content Security Policy (CSP) for Captain Compliance
A Content Security Policy (CSP) is an HTTP response header that tells browsers which origins may load resources on your site. CSP is opt-in: if your site does not send a Content-Security-Policy header, no configuration is needed and Captain Compliance loads without restriction.
If your site does send a CSP, its directives must allow the Captain Compliance origins. Otherwise browsers may block Captain Compliance scripts, API calls, and geolocation lookups, and the consent banner can fail silently or log console errors.
Required origins
Origin | Purpose |
|---|---|
| Loads the Captain Compliance script bundle, posts consent records, and pulls banner styles and assets. |
| Returns the visitor’s public IP address as JSON. Used alongside Cloudflare headers to detect the visitor’s jurisdiction. |
Directives to update
Add the origins to the directives your policy already uses. If your policy only sets default-src, add them there.
Directive | Add | Why |
|---|---|---|
|
| Loads the banner script and the regional consent defaults. |
|
| Sends API requests, consent records, and the geolocation lookup. |
|
| Loads banner images and assets. |
|
| The banner injects its styles as inline style elements at runtime. A style-src directive without this keyword blocks them. |
|
| Only needed if you embed a hosted privacy notice in an iframe. |
Example directives to merge into your existing policy:
script-src 'self' https://*.cptn.co;
connect-src 'self' https://*.cptn.co https://api.ipify.org;
img-src 'self' https://*.cptn.co;
style-src 'self' 'unsafe-inline';
frame-src 'self' https://*.cptn.coIf you deploy through Google Tag Manager, your policy must also allow GTM itself. See Google’s guide to using Tag Manager with a Content Security Policy.
Other Captain Compliance features
The embedded DSR portal loads its script from
api-prod.cptn.co, which thescript-srcentry above already covers. See How to Generate and Customize a Data Subject Request (DSR) Portal.Links to hosted pages, such as a privacy notice, a DSR portal, or a cookie transparency page, are ordinary links and need no CSP change.
Verify
Load your site in a private or incognito browser window.
Open browser developer tools and select the Console tab.
Look for Content Security Policy errors that mention
cptn.cooripify.org. Each error names the directive that blocked the request, so add the origin to that directive.Confirm the consent banner appears and responds to clicks.
