File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ function getColoredDuration(ms: number): string {
6666 * Get client IP address from various headers
6767 */
6868function getClientIP ( request : NextRequest ) : string {
69- // Check various headers that might contain the real IP
69+ // In Docker with nginx as reverse proxy, ensure nginx sets X-Forwarded-For and X-Real-IP headers
7070 const xForwardedFor = request . headers . get ( 'x-forwarded-for' )
7171 const xRealIP = request . headers . get ( 'x-real-ip' )
7272 const cfConnectingIP = request . headers . get ( 'cf-connecting-ip' )
@@ -123,10 +123,14 @@ export function middleware(request: NextRequest): NextResponse {
123123 // Log the request immediately (before processing)
124124 const timestamp = new Date ( ) . toISOString ( )
125125 const fullUrl = pathname + search
126+ const status = response . status
127+ const duration = Date . now ( ) - startTime
126128
127129 logger . info (
128130 `${ colors . gray } [${ timestamp } ]${ colors . reset } ` +
129131 `${ getColoredMethod ( method ) } ` +
132+ `${ getColoredStatus ( status ) } ` +
133+ `${ getColoredDuration ( duration ) } ` +
130134 `${ colors . cyan } ${ fullUrl } ${ colors . reset } ` +
131135 `${ colors . gray } from ${ clientIP } ${ colors . reset } `
132136 )
You can’t perform that action at this time.
0 commit comments