Include status in result log

This commit is contained in:
Konstantin Wohlwend 2025-03-02 16:31:14 -08:00
parent 042745a4be
commit 30e27906ec

View File

@ -106,7 +106,7 @@ export function handleApiRequest(handler: (req: NextRequest, options: any, reque
if ([301, 302].includes(res.status)) {
throw new StackAssertionError("HTTP status codes 301 and 302 should not be returned by our APIs because the behavior for non-GET methods is inconsistent across implementations. Use 303 (to rewrite method to GET) or 307/308 (to preserve the original method and data) instead.", { status: res.status, url: req.nextUrl, req, res });
}
if (!disableExtendedLogging) console.log(`[ RES] [${requestId}] ${req.method} ${censoredUrl} (in ${time.toFixed(0)}ms)`);
if (!disableExtendedLogging) console.log(`[ RES] [${requestId}] ${req.method} ${censoredUrl}: ${res.status} (in ${time.toFixed(0)}ms)`);
return res;
} catch (e) {
let statusError: StatusError;