initial migration

This commit is contained in:
2025-12-28 23:28:31 +01:00
parent 1f99781458
commit 292975299d
284 changed files with 119466 additions and 0 deletions

42
middleware.ts Normal file
View File

@@ -0,0 +1,42 @@
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).*)',
],
}