You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/content/1.documentation/5.advanced/3.strict-csp.md
+29-1
Original file line number
Diff line number
Diff line change
@@ -669,16 +669,42 @@ Nuxt Security uses a different approach, depending on whether SSR or SSG is used
669
669
670
670
**CSP Headers for SSG via Nitro Presets**
671
671
672
+
Nuxt Security supports CSP via HTTP headers for Nitro Presets that generate HTTP headers.
673
+
672
674
When using the SSG mode, some static hosting services such as Vercel or Netlify provide the ability to specify a configuration file that governs the value of the headers that will be generated. When these hosting services benefit from a [Nitro Preset](https://nitro.unjs.io/deploy/#overview), it is possible for Nuxt Security to predict the value of the CSP headers for each page and write the value to the configuration file.
673
675
674
-
Nuxt Security supports CSP via HTTP headers for Nitro Presets that output HTTP headers.
676
+
This feature is enabled by default with the `ssg: exportToPresets` option.
675
677
676
678
::alert{type="info"}
677
679
If you deploy your SSG site on Vercel or Netlify, you will benefit automatically from CSP Headers.
678
680
<br>
679
681
CSP will be delivered via HTTP headers, in addition to the standard `<meta http-equiv>` approach. If you want to disable the meta tag, so that only the HTTP headers are used, you can do so with the `ssg: meta` option.
680
682
::
681
683
684
+
**CSP Headers for SSG via `prerenderedHeaders` hook**
685
+
686
+
Nuxt Security allows you to generate your own headers rules with the `nuxt-security:prerenderedHeaders` buildtime hook.
687
+
688
+
If you do not deploy with a Nitro preset, or if you have specific requirements that are not met by the `ssg: exportToPresets` default, you can use this hook to generate your headers configuration file yourself.
689
+
690
+
See our documentation on the [prerenderedPages hook](/documentation/advanced/hooks/#prerendered-headers-hook)
691
+
692
+
::alert{type="info"}
693
+
This will allow you to deliver CSP via HTTP headers, in addition to the standard `<meta http-equiv>` approach.
694
+
::
695
+
696
+
**CSP Headers for Hybrid Pre-Rendered Pages**
697
+
698
+
Nuxt Security supports CSP via HTTP headers for pre-rendered pages of Hybrid applications.
699
+
700
+
This feature is enabled by default with the `ssg: nitroHeaders` option.
701
+
702
+
::alert{type="info"}
703
+
In Hybrid applications, CSP of pre-rendered pages will be delivered via HTTP headers, in addition to the standard `<meta http-equiv>` approach.
704
+
<br>
705
+
If you want to disable the meta tag, so that only the HTTP headers are used, you can do so with the `ssg: meta` option.
706
+
::
707
+
682
708
### Per Route CSP
683
709
684
710
Nuxt Security gives you the ability to define per-route CSP. For instance, you can have Strict CSP on the admin section of your application, and a more relaxed policy on the blog section.
0 commit comments