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,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">
|
||||||
|
|||||||
Reference in New Issue
Block a user