← back to Grant
app/page.tsx
18 lines
import { cookies } from 'next/headers';
import AppShell from '@/components/AppShell';
import Landing from '@/components/landing/Landing';
import { verifyAuth } from '@/lib/auth';
// Auth-branch the root route: signed-in visitors get the app, everyone else
// the public fit-feed landing. Read the cookie via the canonical cookies()
// API — headers().get('cookie') came back empty in the prod RSC render — and
// verify with verifyAuth (the verifier this build exports).
export default async function Home() {
const jar = await cookies();
const cookieHeader = jar.getAll().map((c) => `${c.name}=${c.value}`).join('; ');
const shim = { headers: { get: (k: string) => (k.toLowerCase() === 'cookie' ? cookieHeader : null) } };
const session = verifyAuth(shim as unknown as Request);
return session ? <AppShell /> : <Landing />;
}