What is a CSP?
A Content Security Policy (CSP) is a security feature that prevents unauthorized scripts or styles from being injected into your application. It works by explicitly allowing (or blocking) resources based on source, path, or nonce. Without proper CSP configuration, your browser may block the Adopt AI SDK from running.Supporting CSP with Adopt
Adopt supports two approaches for working with CSP-secured environments:Option 1: Script / CDN with Auto-Detected Nonce
If you’re using the Script/CDN method, you can pass the nonce directly into the script tag via adata-nonce
attribute. Adopt will automatically detect and use it.
Example →
Note - The SDK will automatically pick up and use the nonce to comply with your CSP.
Option 2: NPM Package with Manual Nonce
If you’re using the NPM package, you’ll need to pass the nonce explicitly when callinginit()
.
Example →
Make sure the nonce matches the one declared in your CSP meta tag. Otherwise, the browser may still block execution.
Good to Know
- All Adopt-hosted resources (SDK, assets, etc.) are served over HTTPS from
https://*.adopt.ai
- Adopt does not inject third-party scripts
- You only need to handle CSP/nonce setup if you already have CSP enabled on your app