Skip to content

Commit 00726f9

Browse files
committed
fix: hotfix middleware redirect available languages
1 parent 280c12b commit 00726f9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

middleware.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export const middleware = async (request: NextRequest) => {
1919

2020
// If we already have a NEXT_LOCALE Cookie, then Redirect to the stored Locale Code
2121
if (localeCookie?.value && localeCookie.value !== 'default') {
22-
return redirectWithLocale(localeCookie.value);
22+
// If the language by any reason is not available anymore, ignore the cookie
23+
if (availableLocales.some(locale => locale.code === localeCookie.value)) {
24+
return redirectWithLocale(localeCookie.value);
25+
}
2326
}
2427

2528
// If not, we try to check if the Browser is sending `Accept-Language` Header

0 commit comments

Comments
 (0)