From 689315892636f5e807ff44ebcfc2f262c8a51d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sat, 29 Nov 2025 17:56:28 +0100 Subject: [PATCH] feat: migrate middleware.ts to proxy.ts - Rename middleware.ts to proxy.ts using Next.js codemod - Update function name from 'middleware' to 'proxy' - Update documentation in I18N.md to reflect proxy.ts usage - Maintain all existing functionality (i18n routing and security headers) --- I18N.md | 8 ++++---- middleware.ts => proxy.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename middleware.ts => proxy.ts (96%) diff --git a/I18N.md b/I18N.md index fdeb21b..1498eb1 100644 --- a/I18N.md +++ b/I18N.md @@ -191,9 +191,9 @@ Bestehende Daten werden automatisch migriert: **Wichtig:** Alte String-Werte werden automatisch in beide Sprachen kopiert: - `"Rock"` → `{ "de": "Rock", "en": "Rock" }` -## Middleware +## Proxy -Die Middleware (`middleware.ts`) leitet Anfragen automatisch um: +Der Proxy (`proxy.ts`) leitet Anfragen automatisch um: - `/` → `/de` (Standard) - Ungültige Locales → 404 @@ -268,7 +268,7 @@ const name = getLocalizedValue(genre.name, locale, 'Unbekannt'); **Problem:** Route wird nicht gefunden. **Lösung:** -1. Überprüfe, ob `middleware.ts` korrekt konfiguriert ist +1. Überprüfe, ob `proxy.ts` korrekt konfiguriert ist 2. Stelle sicher, dass `app/[locale]/layout.tsx` existiert 3. Prüfe die `i18n/request.ts` Konfiguration @@ -325,7 +325,7 @@ Um eine neue Sprache hinzuzufügen (z.B. Französisch): 3. **Locale zur Konfiguration hinzufügen:** - `i18n/request.ts`: `const locales = ['en', 'de', 'fr'];` - - `middleware.ts`: `locales: ['en', 'de', 'fr']` + - `proxy.ts`: `locales: ['en', 'de', 'fr']` - `lib/navigation.ts`: `export const locales = ['de', 'en', 'fr'] as const;` 4. **Layout aktualisieren:** diff --git a/middleware.ts b/proxy.ts similarity index 96% rename from middleware.ts rename to proxy.ts index 33cf2d4..3d5c3c2 100644 --- a/middleware.ts +++ b/proxy.ts @@ -8,7 +8,7 @@ const i18nMiddleware = createMiddleware({ localePrefix: 'always' }); -export default function middleware(request: NextRequest) { +export default function proxy(request: NextRequest) { // 1. i18n-Routing const response = i18nMiddleware(request);