fix: remove middleware redirect, let login page handle auth check
This commit is contained in:
+3
-14
@@ -1,21 +1,10 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import type { NextRequest } from 'next/server';
|
||||
|
||||
// Simple middleware for Next.js Edge Runtime
|
||||
// This is a basic implementation that doesn't verify tokens
|
||||
// In a production environment, you would want to verify the token
|
||||
// Middleware runs on edge runtime - we can't verify JWT here easily
|
||||
// Let the pages handle auth checks via /api/auth/me
|
||||
export function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
const token = request.cookies.get('session')?.value;
|
||||
|
||||
// Protect admin routes - let page handle auth UI
|
||||
// No redirect here; the admin page shows login prompt if not authenticated
|
||||
|
||||
// If logged in and trying to access login, redirect to admin
|
||||
if (pathname === '/login' && token) {
|
||||
return NextResponse.redirect(new URL('/admin', request.url));
|
||||
}
|
||||
|
||||
// No redirects - login and admin pages handle their own auth UI
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user