Skip to content

Commit

Permalink
fix: use console warn instead of useLogger
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Sthamer <[email protected]>
  • Loading branch information
P4sca1 committed Aug 3, 2024
1 parent 57ff90b commit 1a5ada9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/runtime/nitro/plugins/50-updateCsp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineNitroPlugin } from '#imports'
import { resolveSecurityRules } from '../context'
import type { ContentSecurityPolicyValue } from '../../../types/headers'
import { useLogger } from '@nuxt/kit'

/**
* This plugin updates the CSP directives with the nonce and hashes generated by the server.
Expand Down Expand Up @@ -30,8 +29,6 @@ export default defineNitroPlugin((nitroApp) => {
})

function updateCspVariables(csp: ContentSecurityPolicyValue, nonce?: string, scriptHashes?: Set<string>, styleHashes?: Set<string>) {
const logger = useLogger('nuxt-security')

const generatedCsp = <ContentSecurityPolicyValue>Object.fromEntries(Object.entries(csp).map(([directive, value]) => {
// Return boolean values unchanged
if (typeof value === 'boolean') {
Expand All @@ -42,7 +39,7 @@ function updateCspVariables(csp: ContentSecurityPolicyValue, nonce?: string, scr
const modifiedSources = sources
.filter(source => {
if (source.startsWith("'nonce-") && source !== "'nonce-{{nonce}}'") {
logger.warn('Removing static nonce from CSP header.')
console.warn('[nuxt-security] removing static nonce from CSP header')
return false
}
return true
Expand Down

0 comments on commit 1a5ada9

Please sign in to comment.