Skip to content

Commit a7517f9

Browse files
committed
test
1 parent 0836ce3 commit a7517f9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/security/security-headers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// lib/security-headers.ts
2-
import crypto from 'crypto';
32
import { NextRequest, NextResponse } from 'next/server';
43
import React from 'react';
54

6-
// Generate nonce for CSP
5+
// Generate nonce for CSP using Web Crypto API (Edge Runtime compatible)
76
export function generateNonce(): string {
8-
return crypto.randomBytes(16).toString('base64');
7+
const array = new Uint8Array(16);
8+
crypto.getRandomValues(array);
9+
return btoa(String.fromCharCode(...array));
910
}
1011

1112
// Security headers configuration

0 commit comments

Comments
 (0)