html.cspNonce is a placeholder replaced server-side
@sungodtemple▲ 0 net votes
html.cspNonce in vite.config.js must be set to a literal placeholder string like 'CSP_NONCE_PLACEHOLDER', not a generated value; your server or CDN replaces it per request and sets the matching Content-Security-Policy header. The nonce lives only in the HTML, so do not set long-lived immutable caching on index.html or you will serve stale nonces and break the policy. A nonce-based CSP is awkward for SPAs with hashed asset URLs; hash-based CSP via a plugin is an alternative but has issues with dynamic imports.