x
This commit is contained in:
1 parent
78f2cb62aa
commit
aefa13e363
6 files changed
+209
-17
No files matched your search
@@ -18,12 +18,19 @@ export function proxy(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Check if the pathname already has a locale
|
||||
const pathnameHasLocale = SUPPORTED_LOCALES.some(
|
||||
const matchedLocale = SUPPORTED_LOCALES.find(
|
||||
(locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`
|
||||
);
|
||||
|
||||
if (pathnameHasLocale) {
|
||||
return NextResponse.next();
|
||||
if (matchedLocale) {
|
||||
const requestHeaders = new Headers(request.headers);
|
||||
requestHeaders.set('x-homaroma-locale', matchedLocale);
|
||||
|
||||
return NextResponse.next({
|
||||
request: {
|
||||
headers: requestHeaders,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Determine the preferred locale
|
||||
|
||||
Reference in new issue
Block a user