Skip to main content

DOCS_CSP

Constant DOCS_CSP 

Source
pub const DOCS_CSP: &str = "default-src 'none'; \
    script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; \
    style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; \
    img-src 'self' data: https://cdn.jsdelivr.net; \
    font-src 'self' data: https://cdn.jsdelivr.net; \
    connect-src 'self' https://cdn.jsdelivr.net; \
    worker-src 'self' blob:; \
    child-src 'self' blob:; \
    frame-ancestors 'none'";
Expand description

The Content-Security-Policy for the documentation pages — narrower than a wildcard, wider than the API’s default-src 'none'. It permits only what the viewers need: their scripts and styles from jsDelivr (plus the inline bootstrap), data/CDN images and fonts, a same-origin fetch of /openapi.json, and blob: web workers (ReDoc renders in a worker). Everything else stays denied, so the documentation pages are no softer than they must be.