This commit is contained in:
2026-04-19 17:23:31 +03:00
parent 9cad199125
commit 4f2188363a
122 changed files with 3215 additions and 116 deletions

26
middleware.ts Normal file
View File

@@ -0,0 +1,26 @@
import { NextResponse, type NextRequest } from 'next/server'
let locales = ['en', 'tr']
let defaultLocale = 'tr'
export function middleware(request: NextRequest) {
// Check if there is any supported locale in the pathname
const { pathname } = request.nextUrl
const pathnameHasLocale = locales.some(
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
)
if (pathnameHasLocale) return
// Redirect if there is no locale
request.nextUrl.pathname = `/${defaultLocale}${pathname}`
// e.g. incoming is /about -> /tr/about
return NextResponse.redirect(request.nextUrl)
}
export const config = {
matcher: [
// Skip all internal paths (_next)
'/((?!api|_next/static|_next/image|favicon.ico|logo.png|images|.*\\..*).*)',
],
}