This commit is contained in:
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`
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user