mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-03 11:11:48 +02:00
🐛Default to en locale in middleware
This commit is contained in:
parent
1cf242d134
commit
3da803a41a
1 changed files with 5 additions and 10 deletions
|
@ -29,17 +29,12 @@ export default withAuth(
|
||||||
} else {
|
} else {
|
||||||
// Check if locale is specified in header
|
// Check if locale is specified in header
|
||||||
const acceptLanguageHeader = headers.get("accept-language");
|
const acceptLanguageHeader = headers.get("accept-language");
|
||||||
|
const localeFromHeader = acceptLanguageHeader
|
||||||
|
? languageParser.pick(supportedLocales, acceptLanguageHeader)
|
||||||
|
: null;
|
||||||
|
const locale = localeFromHeader ?? "en";
|
||||||
|
|
||||||
if (acceptLanguageHeader) {
|
newUrl.pathname = `/${locale}${newUrl.pathname}`;
|
||||||
const locale = languageParser.pick(
|
|
||||||
supportedLocales,
|
|
||||||
acceptLanguageHeader,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (locale) {
|
|
||||||
newUrl.pathname = `/${locale}${newUrl.pathname}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = NextResponse.rewrite(newUrl);
|
const res = NextResponse.rewrite(newUrl);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue