Fix home page redirect for unauthenticated users
- Check session before calling getLists() - Redirect to login page if not authenticated - Prevents server component render error in production
This commit is contained in:
@@ -5,12 +5,19 @@ import GlobalSearch from '@/components/GlobalSearch'
|
||||
import EmptyState from '@/components/EmptyState'
|
||||
import Link from 'next/link'
|
||||
import { auth } from '@/auth'
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
export default async function Home() {
|
||||
const lists = await getLists()
|
||||
const session = await auth()
|
||||
|
||||
// Redirect to login if not authenticated
|
||||
if (!session?.user) {
|
||||
redirect('/auth/login')
|
||||
}
|
||||
|
||||
const lists = await getLists()
|
||||
|
||||
return (
|
||||
<main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-7xl">
|
||||
|
||||
Reference in New Issue
Block a user