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)
This commit is contained in:
8
I18N.md
8
I18N.md
@@ -191,9 +191,9 @@ Bestehende Daten werden automatisch migriert:
|
|||||||
**Wichtig:** Alte String-Werte werden automatisch in beide Sprachen kopiert:
|
**Wichtig:** Alte String-Werte werden automatisch in beide Sprachen kopiert:
|
||||||
- `"Rock"` → `{ "de": "Rock", "en": "Rock" }`
|
- `"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)
|
- `/` → `/de` (Standard)
|
||||||
- Ungültige Locales → 404
|
- Ungültige Locales → 404
|
||||||
@@ -268,7 +268,7 @@ const name = getLocalizedValue(genre.name, locale, 'Unbekannt');
|
|||||||
**Problem:** Route wird nicht gefunden.
|
**Problem:** Route wird nicht gefunden.
|
||||||
|
|
||||||
**Lösung:**
|
**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
|
2. Stelle sicher, dass `app/[locale]/layout.tsx` existiert
|
||||||
3. Prüfe die `i18n/request.ts` Konfiguration
|
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:**
|
3. **Locale zur Konfiguration hinzufügen:**
|
||||||
- `i18n/request.ts`: `const locales = ['en', 'de', 'fr'];`
|
- `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;`
|
- `lib/navigation.ts`: `export const locales = ['de', 'en', 'fr'] as const;`
|
||||||
|
|
||||||
4. **Layout aktualisieren:**
|
4. **Layout aktualisieren:**
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const i18nMiddleware = createMiddleware({
|
|||||||
localePrefix: 'always'
|
localePrefix: 'always'
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function middleware(request: NextRequest) {
|
export default function proxy(request: NextRequest) {
|
||||||
// 1. i18n-Routing
|
// 1. i18n-Routing
|
||||||
const response = i18nMiddleware(request);
|
const response = i18nMiddleware(request);
|
||||||
|
|
||||||
Reference in New Issue
Block a user