21 lines
432 B
TypeScript
21 lines
432 B
TypeScript
// app/(protected)/layout.tsx
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
import { createClient } from '@/lib/supabase/server'
|
|
import { redirect } from 'next/navigation'
|
|
|
|
export default async function ProtectedLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
const supabase = await createClient()
|
|
const {
|
|
data: { user },
|
|
} = await supabase.auth.getUser()
|
|
|
|
if (!user) redirect('/login')
|
|
|
|
return <>{children}</>
|
|
}
|