update log
All checks were successful
Deploy Website / deploy (push) Successful in 3m50s

This commit is contained in:
Lee 2024-10-10 02:50:43 +01:00
parent 130016957d
commit 6b2f9fa308

@ -4,12 +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;
const ip = request.headers.get("CF-Connecting-IP") || request.headers.get("X-Forwarded-For") || request.ip;
// Log requests in production
if (isProduction()) {
console.log(
` ${request.method} ${request.nextUrl.pathname}${connectingIp != undefined ? ` ${connectingIp}` : ""} ${response.status} in ${(Date.now() - before).toFixed(0)}ms`
` ${ip} | ${request.method} ${request.nextUrl.pathname} ${response.status} in ${(Date.now() - before).toFixed(0)}ms`
);
}