fix routing
This commit is contained in:
+5
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user