fix routing

This commit is contained in:
smanylov
2026-04-08 14:25:27 +07:00
parent fc57df29bc
commit affe9699df
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -32,11 +32,15 @@ export default async function proxy(request: NextRequest) {
if (!isPublicPage) {
const cookie = (await cookies()).get('session')?.value;
const session = await decrypt(cookie);
const targetLocale = isValidLocale ? locale : routing.defaultLocale;
if (!session?.token) {
const targetLocale = isValidLocale ? locale : routing.defaultLocale;
const loginUrl = new URL(`/${targetLocale}/login`, request.url);
return NextResponse.redirect(loginUrl);
} else if (path === '/en' || path === '/ru') {
const dashboardUrl = new URL(`/${targetLocale}/pages`, request.url);
dashboardUrl.search = new URL(request.url).search;
return NextResponse.redirect(dashboardUrl);
}
}