diff --git a/projects/website/src/middleware.ts b/projects/website/src/middleware.ts index 7e6bba3..87b2a99 100644 --- a/projects/website/src/middleware.ts +++ b/projects/website/src/middleware.ts @@ -4,11 +4,12 @@ import { isProduction } from "@ssr/common/utils/utils"; export function middleware(request: NextRequest) { const before = Date.now(); const response = NextResponse.next(); + const connectingIp = request.headers.get("CF-Connecting-IP") || request.ip; // Log requests in production - if (isProduction()) { + if (!isProduction()) { console.log( - ` ${request.method} ${request.nextUrl.pathname} ${response.status} in ${(Date.now() - before).toFixed(0)}ms` + ` ${request.method} ${request.nextUrl.pathname}${connectingIp != undefined ? ` ${connectingIp}` : ""} ${response.status} in ${(Date.now() - before).toFixed(0)}ms` ); }