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