@@ -3,6 +3,7 @@ import { baseLogSchema } from "./schemas"
33import { z } from "zod"
44import { headersToRecord , parseJsonOrPassthrough } from "./utils"
55import { AddContextFn , FlushFn } from "./types"
6+ import { headers } from "next/headers"
67
78export function response (
89 body : BodyInit ,
@@ -78,14 +79,14 @@ export async function parseText(
7879
7980export function catchUncaughtRoute <
8081 RequestType extends Request ,
81- T extends { params : Record < string , unknown > }
82+ T extends { params : Record < string , unknown > } ,
8283> (
8384 fn : ( request : RequestType , context : T ) => Promise < Response > | Response ,
8485 addContext : AddContextFn < z . infer < typeof baseLogSchema > > ,
8586 flush : FlushFn ,
8687 options ?: Partial < z . infer < typeof baseLogSchema > >
87- ) : ( request : Request , context : T ) => Promise < Response > {
88- return async ( request : Request , context : T ) => {
88+ ) : ( request : RequestType , context : T ) => Promise < Response > {
89+ return async ( request : RequestType , context : T ) => {
8990 const t0 = Date . now ( )
9091 if ( options ) addContext ( options )
9192 try {
@@ -137,6 +138,9 @@ export function catchUncaughtAction<T extends (...args: any[]) => Promise<any>>(
137138 const t0 = Date . now ( )
138139 if ( options ) addContext ( options )
139140 try {
141+ addContext ( {
142+ req_headers : headersToRecord ( headers ( ) ) ,
143+ } )
140144 addContext ( {
141145 req : args ,
142146 } )
0 commit comments