n8n/packages/@n8n/constants/src/csp.ts
Luigi Gubello 54b2b94d56
feat(core): Serve a nonce-based Content-Security-Policy on n8n's HTML pages (#36749)
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 16:39:04 +00:00

14 lines
607 B
TypeScript

/**
* Placeholder that the frontend build bakes into the tags of the built HTML (via Vite's
* `html.cspNonce`), for the backend to replace with the request's nonce when it serves
* the page. Shared so the two sides cannot drift apart.
*/
export const HTML_NONCE_PLACEHOLDER = '{{CSP_NONCE}}';
/**
* Token that users write in a policy where n8n should substitute the per-request nonce,
* e.g. `N8N_CONTENT_SECURITY_POLICY="script-src <nonce>"`. Shared so the default policy
* in `@n8n/config` and the substitution in `packages/cli` cannot drift apart.
*/
export const NONCE_PLACEHOLDER = '<nonce>';