bugfix: authenticated users seen a blank page instead of their dashboard when reopen the site
This commit is contained in:
@@ -10,6 +10,11 @@ export function middleware(request: NextRequest) {
|
||||
const token = request.cookies.get('accessToken')?.value;
|
||||
const isAuthenticated = !!token;
|
||||
|
||||
// If a logged-in user opens home, send them to dashboard.
|
||||
if (isAuthenticated && pathname === '/') {
|
||||
return NextResponse.redirect(new URL('/today', request.url));
|
||||
}
|
||||
|
||||
// Always allow public routes first
|
||||
if (publicRoutes.includes(pathname)) {
|
||||
// If user is already logged in and tries to access login/register → redirect to dashboard
|
||||
|
||||
Reference in New Issue
Block a user