update the logger
Some checks failed
Deploy Website / deploy (push) Has been cancelled

This commit is contained in:
Lee 2024-10-10 00:39:58 +01:00
parent 886ed4b20c
commit ee45e41d6d

@ -1,9 +1,29 @@
import type { NextRequest } from "next/server"; import { NextResponse, type NextRequest } from "next/server";
import { isProduction } from "@ssr/common/utils/utils"; import { isProduction } from "@ssr/common/utils/utils";
export function middleware(request: NextRequest) { export function middleware(request: NextRequest) {
const before = performance.now();
const response = NextResponse.next();
// Log requests in production // Log requests in production
if (isProduction()) { if (isProduction()) {
console.log(` ${request.method} ${request.url}`); console.log(
` ${request.method} ${request.nextUrl.pathname} ${response.status} in ${(performance.now() - before).toFixed(0)}ms`
);
} }
return response;
} }
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
"/((?!api|_next/static|_next/image|favicon.ico).*)",
],
};