
import { NextResponse, type NextRequest } from 'next/server'

export function middleware(request: NextRequest) {
//   const token = request.cookies.get('token')?.value
//   const { pathname } = request.nextUrl
//     const protectedRoutes = ['/home', '/serveportal', '/campaigns']
//   const isProtectedRoute = protectedRoutes.some(route => 
//     pathname === route || pathname.startsWith(route + '/')
//   )
//   const authRoutes = ['/login', '/register', '/forgot-password']
//   const isAuthRoute = authRoutes.includes(pathname)
//   if (isProtectedRoute && !token) {
//     console.log('Redirecting to login from:', pathname)
//     return NextResponse.redirect(new URL('/', request.url))
//   }
  
//   if (token && isAuthRoute) {
//     return NextResponse.redirect(new URL('/', request.url))
//   }
  
//   return NextResponse.next()
}

export const config = {
  matcher: [
   '/((?!api|_next/static|_next/image|favicon.ico).*)',
  ],
}