diff --git a/lib/request-id.ts b/lib/request-id.ts index 51b6f6ce9..948fb0fed 100644 --- a/lib/request-id.ts +++ b/lib/request-id.ts @@ -1,5 +1,16 @@ import { headers } from 'next/headers'; - +/** + * Retrieves the `x-request-id` header value from the current incoming server request. + * This header is typically set by the hosting platform (e.g., Vercel) or an upstream + * proxy to enable request tracing and log correlation. + * + * @returns The request ID string if present, or null if the header is absent. + * @example + * ```ts + * const requestId = await getRequestId(); + * console.log(requestId); // "req_abc123xyz" + * ``` + */ export async function getRequestId() { const h = await headers(); return h.get('x-request-id');