This commit is contained in:
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).*)",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user