import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; import createMiddleware from "next-intl/middleware"; const intlMiddleware = createMiddleware({ // A list of all locales that are supported locales: ["de"], // Used when no locale matches defaultLocale: "de", // Use default locale without prefix localePrefix: "as-needed", }); export default function middleware(request: NextRequest) { const { pathname } = request.nextUrl; // Explicit bypass for analytics and error tracking paths if (pathname.startsWith("/stats") || pathname.startsWith("/errors")) { return NextResponse.next(); } return intlMiddleware(request); } export const config = { // Matcher for all pages and internationalized pathnames // excluding api, _next, static files, etc. matcher: [ "/((?!api|admin|stats|errors|_next|_vercel|.*\\..*).*)", "/", "/(de)/:path*", ], };