Skip to content

Commit

Permalink
Merge branch 'extend-ssg-csp' into demo-docs-security
Browse files Browse the repository at this point in the history
  • Loading branch information
vejja committed Oct 31, 2023
2 parents 17c908b + 32a2b43 commit 5a901b2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/defaultConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ModuleOptions } from './types'
import type { ModuleOptions } from './types'

const defaultThrowErrorValue = { throwError: true }

Expand Down Expand Up @@ -81,6 +81,7 @@ export const defaultSecurityConfig = (serverlUrl: string): ModuleOptions => ({
exclude: [/node_modules/, /\.git/]
},
ssg: {
hashScripts: true
hashScripts: true,
hashStyles: false
}
})
2 changes: 1 addition & 1 deletion src/runtime/nitro/plugins/02-cspSsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default defineNitroPlugin((nitroApp) => {
// Remove '""'
tagPolicies['script-src'] = (tagPolicies['script-src'] ?? []).concat(scriptHashes)
}
if (styleHashes.length > 0 && moduleOptions.ssg?.hashScripts) {
if (styleHashes.length > 0 && moduleOptions.ssg?.hashStyles) {
// Remove '""'
tagPolicies['style-src'] = (tagPolicies['style-src'] ?? []).concat(styleHashes)
}
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { AllowedHTTPMethods, BasicAuth, CorsOptions, RateLimiter, RequestSi

export type Ssg = {
hashScripts?: boolean;
hashStyles?: boolean;
};

export interface ModuleOptions {
Expand Down

0 comments on commit 5a901b2

Please sign in to comment.