From a7dffbf830b28986dece279577d31b9e06535a5b Mon Sep 17 00:00:00 2001 From: allykeightley Date: Thu, 13 Aug 2026 08:48:37 -0700 Subject: [PATCH] fix(my): render /my dynamically so Clerk auth() can read headers Switch /my from ISR (revalidate) to force-dynamic. auth() reads request headers, which threw DYNAMIC_SERVER_USAGE under static generation in a production build (signed-in only; middleware redirects signed-out users before the page runs). Also removes the temporary diagnostic logging. Co-authored-by: Cursor --- web/app/my/page.tsx | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/web/app/my/page.tsx b/web/app/my/page.tsx index cc73ec0..7dfd3a2 100644 --- a/web/app/my/page.tsx +++ b/web/app/my/page.tsx @@ -4,8 +4,11 @@ import { loadHackathons } from "@/lib/listings"; import { MyClient } from "@/components/hq/my-client"; import { isClerkConfigured } from "@/lib/env"; -// ISR: keep deadline-derived status/countdowns fresh without a rebuild (#47). -export const revalidate = 3600; +// /my calls auth(), which reads request headers, so it must render per request: +// combining that with ISR (revalidate) throws DYNAMIC_SERVER_USAGE in a +// production build. force-dynamic also keeps deadline-derived countdowns fresh, +// which is the reason #47 originally set revalidate here. +export const dynamic = "force-dynamic"; export const metadata = { title: "My HackHQ ยท Members Hub", @@ -15,46 +18,13 @@ export const metadata = { export default async function MyPage() { if (isClerkConfigured()) { - let userId: string | null = null; - try { - const authResult = await auth(); - userId = authResult.userId; - // TEMP DIAGNOSTIC: safe metadata only - no tokens/cookies/JWTs/PII. - console.log("CLERK AUTH OK ON /my", { - hasUserId: Boolean(authResult.userId), - hasSessionId: Boolean(authResult.sessionId), - }); - } catch (error) { - // TEMP DIAGNOSTIC: log the ORIGINAL auth exception before Next.js - // sanitizes it in the production Server Components error. - console.error("CLERK AUTH FAILURE ON /my", { - error, - message: error instanceof Error ? error.message : undefined, - stack: error instanceof Error ? error.stack : undefined, - cause: error instanceof Error ? error.cause : undefined, - }); - throw error; - } - // Kept outside the try so Next's redirect control-flow isn't caught/logged. + const { userId } = await auth(); if (!userId) { redirect("/auth/sign-in?redirect_url=/my"); } } - // TEMP DIAGNOSTIC: distinguish a data/render throw from an auth throw. - let hackathons: ReturnType; - try { - hackathons = loadHackathons(); - } catch (error) { - console.error("DATA FAILURE ON /my (loadHackathons)", { - error, - message: error instanceof Error ? error.message : undefined, - stack: error instanceof Error ? error.stack : undefined, - cause: error instanceof Error ? error.cause : undefined, - }); - throw error; - } - + const hackathons = loadHackathons(); return ( );