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:
2025-12-02 12:40:15 +00:00
parent c51bc28d67
commit 92401c5324

View File

@@ -5,13 +5,20 @@ import GlobalSearch from '@/components/GlobalSearch'
import EmptyState from '@/components/EmptyState' import EmptyState from '@/components/EmptyState'
import Link from 'next/link' import Link from 'next/link'
import { auth } from '@/auth' import { auth } from '@/auth'
import { redirect } from 'next/navigation'
export const dynamic = 'force-dynamic' export const dynamic = 'force-dynamic'
export default async function Home() { export default async function Home() {
const lists = await getLists()
const session = await auth() const session = await auth()
// Redirect to login if not authenticated
if (!session?.user) {
redirect('/auth/login')
}
const lists = await getLists()
return ( return (
<main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-7xl"> <main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-7xl">
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6 sm:mb-8"> <div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6 sm:mb-8">