Files
novi-lessons/Les05-NextJS-Basics/quickpoll-starter/src/middleware.ts
2026-03-11 14:07:00 +01:00

18 lines
458 B
TypeScript

import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";
export function middleware(request: NextRequest): NextResponse {
const start = Date.now();
console.log(`[${request.method}] ${request.nextUrl.pathname}`);
const response = NextResponse.next();
response.headers.set("x-request-time", String(Date.now() - start));
return response;
}
export const config = {
matcher: ["/api/:path*", "/poll/:path*"],
};