POSTERAPP_V1/middleware.ts

34 lines
914 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
const supportedLocales = ['tr', 'en', 'de', 'fr']
const defaultLocale = 'de'
export function middleware(request: NextRequest) {
// Mevcut dili al
let locale = request.cookies.get('NEXT_LOCALE')?.value || defaultLocale
// Geçerli bir dil değilse varsayılan dili kullan
if (!supportedLocales.includes(locale)) {
locale = defaultLocale
}
// Yanıta dil bilgisini ekle
const response = NextResponse.next()
response.cookies.set('NEXT_LOCALE', locale)
return response
}
export const config = {
matcher: [
/*
* Match all request paths except for the ones starting with:
* - api (API routes)
* - _next/static (static files)
* - _next/image (image optimization files)
* - favicon.ico (favicon file)
*/
'/((?!api|_next/static|_next/image|favicon.ico).*)',
],
}