Fix languages issues

This commit is contained in:
Luke Vella 2025-04-26 19:34:17 +01:00
parent 88d255da1b
commit 403b2aa1b0
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
7 changed files with 34 additions and 8 deletions

View file

@ -19,7 +19,10 @@ export async function middleware(request: NextRequest) {
return;
}
const locale = getPreferredLocale(request);
const locale = getPreferredLocale({
acceptLanguageHeader: request.headers.get("accept-language") ?? undefined,
});
request.nextUrl.pathname = `/${locale}${pathname}`;
if (locale === "en") {

View file

@ -19,7 +19,12 @@ export const middleware = withAuth(async (req) => {
return NextResponse.redirect(newUrl);
}
const locale = req.auth?.user?.locale || getPreferredLocale(req);
const locale =
req.auth?.user?.locale ||
getPreferredLocale({
acceptLanguageHeader: req.headers.get("accept-language") ?? undefined,
});
if (supportedLocales.includes(locale)) {
newUrl.pathname = `/${locale}${pathname}`;
}