mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 15:32:10 +01:00
- Fix 36+ biome linting issues reducing errors/warnings from 227 to 191 - Replace explicit 'any' types with proper TypeScript interfaces - Fix React hooks dependencies and useCallback patterns - Resolve unused variables and parameter assignment issues - Improve accessibility with proper label associations - Add comprehensive API documentation for admin and security features - Update README.md with accurate PostgreSQL setup and current tech stack - Create complete documentation for audit logging, CSP monitoring, and batch processing - Fix outdated project information and missing developer workflows
29 lines
668 B
TypeScript
29 lines
668 B
TypeScript
import { headers } from "next/headers";
|
|
|
|
/**
|
|
* Get the CSP nonce from request headers (server-side only)
|
|
*/
|
|
export async function getNonce(): Promise<string | undefined> {
|
|
try {
|
|
const headersList = await headers();
|
|
return headersList.get("X-Nonce") || undefined;
|
|
} catch {
|
|
// Headers not available (e.g., in client-side code)
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create script props with nonce for CSP compliance
|
|
*/
|
|
export function createScriptProps(nonce?: string) {
|
|
return nonce ? { nonce } : {};
|
|
}
|
|
|
|
/**
|
|
* Create style props with nonce for CSP compliance
|
|
*/
|
|
export function createStyleProps(nonce?: string) {
|
|
return nonce ? { nonce } : {};
|
|
}
|