This commit is contained in:
2026-01-16 19:31:01 +01:00
parent 53fc83e182
commit ffbb240a23
444 changed files with 9 additions and 16233 deletions

View File

@@ -1,42 +0,0 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
// List of supported locales
const locales = ['en', 'de']
const defaultLocale = 'en'
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl
// Skip middleware for static files and API routes
if (
pathname.startsWith('/_next') ||
pathname.startsWith('/api/') ||
pathname.startsWith('/media/') ||
pathname.includes('.') // Skip files with extensions
) {
return NextResponse.next()
}
// Check if pathname already has a locale
const pathnameHasLocale = locales.some(
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
)
if (pathnameHasLocale) {
// Already has locale, continue
return NextResponse.next()
}
// Add default locale to URL
request.nextUrl.pathname = `/${defaultLocale}${pathname}`
return NextResponse.redirect(request.nextUrl)
}
export const config = {
matcher: [
// Match all paths except static files and API routes
'/((?!_next|api|media|favicon.ico|robots.txt|sitemap.xml).*)',
],
}