30 lines
689 B
TypeScript
30 lines
689 B
TypeScript
import { NextResponse, NextRequest } from 'next/server';
|
|||
|
|
import { cookies } from 'next/headers'
|
||
|
|
import createIntlMiddleware from 'next-intl/middleware'
|
||
|
|
import { routing } from '@/i18n/routing'
|
||
|
|
|
||
|
|
const intlMiddleware = createIntlMiddleware(routing);
|
||
|
|
|
||
|
|
export default async function proxy(request: NextRequest) {
|
||
|
|
const path = request.nextUrl.pathname;
|
||
|
|
|
||
|
|
if (
|
||
|
|
path.startsWith('/_next') ||
|
||
|
|
path.includes('/api/') ||
|
||
|
|
path.includes('.')
|
||
|
|
) {
|
||
|
|
return NextResponse.next()
|
||
|
|
}
|
||
|
|
|
||
|
|
const intlResponse = intlMiddleware(request);
|
||
|
|
|
||
|
|
if (intlResponse) {
|
||
|
|
return intlResponse
|
||
|
|
}
|
||
|
|
|
||
|
|
return NextResponse.next();
|
||
|
|
}
|
||
|
|
|
||
|
|
export const config = {
|
||
|
|
matcher: ['/((?!api|_next/static|_next/image|.*\\.png$).*)']
|
||
|
|
};
|