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 {
66
66
* Get client IP address from various headers
67
67
*/
68
68
function 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
70
70
const xForwardedFor = request . headers . get ( 'x-forwarded-for' )
71
71
const xRealIP = request . headers . get ( 'x-real-ip' )
72
72
const cfConnectingIP = request . headers . get ( 'cf-connecting-ip' )
@@ -123,10 +123,14 @@ export function middleware(request: NextRequest): NextResponse {
123
123
// Log the request immediately (before processing)
124
124
const timestamp = new Date ( ) . toISOString ( )
125
125
const fullUrl = pathname + search
126
+ const status = response . status
127
+ const duration = Date . now ( ) - startTime
126
128
127
129
logger . info (
128
130
`${ colors . gray } [${ timestamp } ]${ colors . reset } ` +
129
131
`${ getColoredMethod ( method ) } ` +
132
+ `${ getColoredStatus ( status ) } ` +
133
+ `${ getColoredDuration ( duration ) } ` +
130
134
`${ colors . cyan } ${ fullUrl } ${ colors . reset } ` +
131
135
`${ colors . gray } from ${ clientIP } ${ colors . reset } `
132
136
)
You can’t perform that action at this time.
0 commit comments