import { routing } from "@/i18n/routing"; import createMiddleware from "next-intl/middleware"; import { NextFetchEvent, NextRequest, NextResponse } from "next/server"; function stackMiddleware(functions: Function[], index = 0): Function { const current = functions[index]; if (current) { const next = stackMiddleware(functions, index + 1); return current(next); } return () => NextResponse.next(); } function localMiddleware() { return async (request: NextRequest, _next: NextFetchEvent) => { const handleI18nRouting = createMiddleware(routing); return handleI18nRouting(request); }; } const whiteRouters = ["/"]; function authMiddleware(next: Function) { return async (request: NextRequest, res: NextResponse) => { const url = request.nextUrl; return next(request, res); }; } export default stackMiddleware([authMiddleware, localMiddleware]); // 创建一个正则表达式对象 export const config = { // todo use this to match the path matcher: ["/", "/(en|br)/:path*"], };