Skip to content
dimmiDocs

Messenger

Content Security Policy for the messenger

Configure Content-Security-Policy directives and script nonces so the dimmi messenger loads on strict pages.

Add <dimmi_host> (https://trydimmi.com on dimmi Cloud, or your self-hosted URL) to three CSP directives:

Directive What to allow
script-src <dimmi_host>, or a nonce with 'strict-dynamic'. Add your CDN origin too if you self-host assets on a CDN.
connect-src <dimmi_host>, plus your proxy origin if you set apiBase.
img-src <dimmi_host> and data:. Add your file storage origin if conversation images use signed storage URLs.
media-src Your file storage origin (needed only for voice messages).
style-src No changes needed.
Content-Security-Policy: script-src 'self' https://trydimmi.com; connect-src 'self' https://trydimmi.com; img-src 'self' https://trydimmi.com data:

Under 'strict-dynamic', browsers ignore host allowlists in script-src. Pass your per-response nonce on the loader script tag (or via the nonce option in any @dimmi package):

Content-Security-Policy: script-src 'nonce-<nonce>' 'strict-dynamic'; connect-src 'self' https://trydimmi.com; img-src 'self' https://trydimmi.com data:
index.html
<script
async
nonce="<nonce>"
src="https://trydimmi.com/widget/v1/loader.js"
data-app-id="<app_id>"
></script>

Replace <nonce> with your server’s per-request nonce and <app_id> with your messenger app ID.