mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-31 09:46:26 +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 {
|
||||
// Check if locale is specified in header
|
||||
const acceptLanguageHeader = headers.get("accept-language");
|
||||
const localeFromHeader = acceptLanguageHeader
|
||||
? languageParser.pick(supportedLocales, acceptLanguageHeader)
|
||||
: null;
|
||||
const locale = localeFromHeader ?? "en";
|
||||
|
||||
if (acceptLanguageHeader) {
|
||||
const locale = languageParser.pick(
|
||||
supportedLocales,
|
||||
acceptLanguageHeader,
|
||||
);
|
||||
|
||||
if (locale) {
|
||||
newUrl.pathname = `/${locale}${newUrl.pathname}`;
|
||||
}
|
||||
}
|
||||
newUrl.pathname = `/${locale}${newUrl.pathname}`;
|
||||
}
|
||||
|
||||
const res = NextResponse.rewrite(newUrl);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue