Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/request-id.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
Loading