← back to Grant
Auth-branch /: read cookie via cookies() API (headers().get came back empty in prod RSC)
330e761f4ca16e20f8d4601e34ae6038d4dd1692 · 2026-05-30 10:01:50 -0700 · Steve Abrams
Files touched
Diff
commit 330e761f4ca16e20f8d4601e34ae6038d4dd1692
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Sat May 30 10:01:50 2026 -0700
Auth-branch /: read cookie via cookies() API (headers().get came back empty in prod RSC)
---
app/page.tsx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/page.tsx b/app/page.tsx
index f374e8f..bf09054 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,15 +1,15 @@
-import { headers } from 'next/headers';
+import { cookies, headers } 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
-// sees the public fit-feed landing. verifyAuth only reads the `cookie` header,
-// so we hand it a minimal shim built from the incoming request headers.
export default async function Home() {
- const cookie = (await headers()).get('cookie') ?? '';
- const shim = { headers: { get: (k: string) => (k.toLowerCase() === 'cookie' ? cookie : null) } };
+ const jar = await cookies();
+ const h = await headers();
+ const cookieHeader = jar.getAll().map((c) => `${c.name}=${c.value}`).join('; ');
+ const rawHeader = h.get('cookie') || '';
+ const shim = { headers: { get: (k: string) => (k.toLowerCase() === 'cookie' ? cookieHeader : null) } };
const session = verifyAuth(shim as unknown as Request);
-
+ console.error(`[PAGE-DEBUG] jarCount=${jar.getAll().length} reconLen=${cookieHeader.length} rawLen=${rawHeader.length} hasGrantAuth=${cookieHeader.includes('grant-auth')} session=${JSON.stringify(session)}`);
return session ? <AppShell /> : <Landing />;
}
← 580b213 SEO (robots/sitemap/OG image/metadata) + reusable deploy.sh
·
back to Grant
·
Remove debug logging from auth-branch page 1967d65 →