Skip to content

Commit

Permalink
[docs] add nonce placeholder to CSP docs (sveltejs#7672)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamerat authored Nov 16, 2022
1 parent de68db8 commit 5d642a1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions documentation/docs/50-api-reference/10-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export default config;

...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates.

To add a nonce for scripts and links manually included in `app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce="%sveltekit.nonce%">`).

When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).

> When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
Expand Down

0 comments on commit 5d642a1

Please sign in to comment.