File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ import { TRUSTED_IMAGE_DOMAINS } from '#server/utils/image-proxy'
44
55/**
66 * Adds Content-Security-Policy and security headers to all HTML responses
7- * via a Nitro route rule. This covers both SSR/ISR pages and prerendered
8- * pages (which don't run server middleware).
7+ * via Nitro route rules. This covers both SSR/ISR pages and prerendered
8+ * pages (which are served as static files on Vercel and don't hit the server).
9+ *
10+ * API routes opt out via `false` to disable the inherited headers.
911 *
1012 * Current policy uses 'unsafe-inline' for scripts and styles because:
1113 * - Nuxt injects inline scripts for hydration and payload transfer
@@ -54,18 +56,15 @@ export default defineNuxtModule({
5456 'Referrer-Policy' : 'strict-origin-when-cross-origin' ,
5557 }
5658
57- // Apply to all page routes via a catch-all rule.
58- // API routes are excluded — CSP doesn't make sense for JSON responses.
5959 nuxt . options . routeRules ??= { }
6060 nuxt . options . routeRules [ '/**' ] = {
6161 ...nuxt . options . routeRules [ '/**' ] ,
6262 headers,
6363 }
64+ // Disable page-specific headers on API routes — CSP doesn't apply to JSON.
6465 nuxt . options . routeRules [ '/api/**' ] = {
6566 ...nuxt . options . routeRules [ '/api/**' ] ,
66- headers : {
67- 'X-Content-Type-Options' : 'nosniff' ,
68- } ,
67+ headers : false ,
6968 }
7069 } ,
7170} )
You can’t perform that action at this time.
0 commit comments