feat(web-next): wire security headers middleware and nonce threading
- Add apps/web-next/middleware.ts calling withSecurityHeaders() from core-shared/security/next; exports matcher config excluding static assets - Update layout.tsx to call getNonce() and render <meta name="csp-nonce"> so client-side JS can read the per-request nonce - Update instrumentation-client.ts to read nonce from csp-nonce meta tag and pass it to initSentryClient for feedbackIntegration CSP compliance - Add nonce option to initSentryClient (InitClientOpts.nonce) and thread styleNonce + scriptNonce into feedbackIntegration when provided - Add middleware test asserting all six headers, prod/dev CSP shape, and x-nonce presence; add feedbackIntegration nonce tests to core-shared Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Metadata } from "next";
|
||||
import { getNonce } from "@repo/core-shared/security/next";
|
||||
import { Providers } from "./providers";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
@@ -6,13 +7,19 @@ export const metadata: Metadata = {
|
||||
description: "Clean Architecture Monorepo Template",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const nonce = await getNonce();
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
{/* nonce exposed to client so instrumentation-client.ts can read it */}
|
||||
<meta name="csp-nonce" content={nonce} />
|
||||
</head>
|
||||
<body>
|
||||
<Providers>{children}</Providers>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user