We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0836ce3 commit a7517f9Copy full SHA for a7517f9
lib/security/security-headers.ts
@@ -1,11 +1,12 @@
1
// lib/security-headers.ts
2
-import crypto from 'crypto';
3
import { NextRequest, NextResponse } from 'next/server';
4
import React from 'react';
5
6
-// Generate nonce for CSP
+// Generate nonce for CSP using Web Crypto API (Edge Runtime compatible)
7
export function generateNonce(): string {
8
- return crypto.randomBytes(16).toString('base64');
+ const array = new Uint8Array(16);
+ crypto.getRandomValues(array);
9
+ return btoa(String.fromCharCode(...array));
10
}
11
12
// Security headers configuration
0 commit comments