A strict Content Security Policy breaks most third-party widgets on first deploy. Chat widgets, analytics, A/B testing scripts β they all inject inline styles, eval code, or load from domains you haven't whitelisted. The fix is not to disable CSP; it is to build it incrementally.
Start in report-only mode
Content-Security-Policy-Report-Only: default-src 'self'; report-uri /csp-reports
Enter fullscreen mode
Exit fullscreen mode
Deploy this header and collect violation reports for a week. The reports tell you exactly which domains and inline patterns your page actually uses.
Build the allowlist from reports
# Parse CSP reports to extract unique violated directives and sources violations = defaultdict ( set ) for report in reports : d = report [ 'csp-report' ] violations [ d [ 'violated-directive' ] ] . add ( d [ 'blocked-uri' ] )
Enter fullscreen mode
Exit fullscreen mode
The output is your allowlist.β¦