Skip to content

Commit

Permalink
fix(nonce): make sure nonce nitro plugin is executed last
Browse files Browse the repository at this point in the history
  • Loading branch information
trijpstra-fourlights committed Jul 18, 2023
1 parent b25342d commit 0c24f69
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,32 +230,32 @@ const registerSecurityNitroPlugins = (
config.plugins.push(
normalize(
fileURLToPath(
new URL("./runtime/nitro/plugins/hidePoweredBy", import.meta.url)
new URL("./runtime/nitro/plugins/01-hidePoweredBy", import.meta.url)
)
)
);
}

// Nitro plugin to enable nonce for CSP
if (nuxt.options.security.nonce) {
// Register nitro plugin to enable CSP for SSG
if (
typeof securityOptions.headers === "object" &&
securityOptions.headers.contentSecurityPolicy
) {
config.plugins.push(
normalize(
fileURLToPath(
new URL("./runtime/nitro/plugins/cspNonce", import.meta.url)
new URL("./runtime/nitro/plugins/02-cspSsg", import.meta.url)
)
)
);
}

// Register nitro plugin to enable CSP for SSG
if (
typeof securityOptions.headers === "object" &&
securityOptions.headers.contentSecurityPolicy
) {
// Nitro plugin to enable nonce for CSP
if (nuxt.options.security.nonce) {
config.plugins.push(
normalize(
fileURLToPath(
new URL("./runtime/nitro/plugins/cspSsg", import.meta.url)
new URL("./runtime/nitro/plugins/99-cspNonce", import.meta.url)
)
)
);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0c24f69

Please sign in to comment.