This commit is contained in:
hailin 2025-03-13 22:33:25 +08:00
parent 6721e9d7c6
commit e5e8981ba5
1 changed files with 4 additions and 26 deletions

View File

@ -1,42 +1,20 @@
// export { auth as middleware } from './auth'
// export const config = {
// matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)']
// }
import { i18nRouter } from 'next-i18n-router'; import { i18nRouter } from 'next-i18n-router';
import i18nConfig from './i18nConfig'; import i18nConfig from './i18nConfig';
import { NextResponse, NextRequest, NextFetchEvent } from 'next/server' import { NextResponse, NextRequest, NextFetchEvent } from 'next/server'
// This function can be marked `async` if using `await` inside // This function can be marked `async` if using `await` inside
export function middleware(req: NextRequest, evt: NextFetchEvent) { export function middleware(req: NextRequest, evt: NextFetchEvent) {
// return NextResponse.redirect(new URL('/home', request.url))
console.log(` // console.log(`
======> // ======>
${req.url} - ${JSON.stringify(req)} - ${req.nextUrl.pathname} // ${req.url} - ${JSON.stringify(req)} - ${req.nextUrl.pathname}
`) // `)
return i18nRouter(req, i18nConfig); return i18nRouter(req, i18nConfig);
} }
// export const config = {
// matcher: [
// "/app",
// "/app/(.*)",
// "/auth/(.*)",
// "/(api|trpc)(.*)",
// "/((?!_next/static|_next/image|images|favicon.ico|$).*)",
// ],
// };
// only applies this middleware to files in the app directory // only applies this middleware to files in the app directory
export const config = { export const config = {
matcher: '/((?!api|static|.*\\..*|_next).*)' matcher: '/((?!api|static|.*\\..*|_next).*)'
}; };
// export const config = {
// matcher: ['/((?!api|_next/static|_next/image|favicon.ico|favicon.png).*)']
// }