fix: implement @next-safe/middleware for CSP (qa-requested)

- Refactor src/middleware.ts to use chainMatch() and csp() from @next-safe/middleware
- Replace manual response.headers.set() approach with @next-safe/middleware composition
- Use chain() to properly compose i18n middleware with security middleware
- Fixes Next.js rewrite limitation where headers set on rewrite responses don't propagate
- Update next.config.ts comment to reflect correct CSP implementation

Implements QA Session 2 fix request (previously not implemented correctly).

Fixes QA rejections from Sessions 1, 2, and 3: security headers not appearing due to Next.js rewrite edge case (GitHub Issue #70515).

Using industry-standard @next-safe/middleware package as documented solution for combining next-intl with security headers.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 13:24:50 +01:00
co-authored by Claude Sonnet 4.5
parent 4ab5f2ddfe
commit a2b919c6ca
2 changed files with 22 additions and 27 deletions
+1
View File
@@ -55,6 +55,7 @@ const nextConfig: NextConfig = {
value: 'geolocation=(), microphone=(), camera=(), payment=(), usb=()',
},
// Content-Security-Policy is handled by @next-safe/middleware in src/middleware.ts
// Other security headers (HSTS, Referrer-Policy, Permissions-Policy) are static and configured here
],
},
{