fix(pre-M3): root page 500 — guard auth() for Clerk test mode#11
Merged
fix(pre-M3): root page 500 — guard auth() for Clerk test mode#11
Conversation
…Clerk test mode Clerk test-mode (pk_test_* keys) throws when auth() is called in a Server Component without the dev-browser cookie. Separated auth() into a guarded try-catch so role is undefined on failure, letting the landing page render normally. redirect() calls remain outside the try-catch so NEXT_REDIRECT still propagates correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ver component use buttonVariants was defined in components/ui/button.tsx which is 'use client' (needed for ButtonPrimitive from @base-ui/react/button). Turbopack enforces the RSC rule: calling a 'use client' function from a Server Component throws at runtime. Fix: move the CVA config to lib/button-variants.ts (no 'use client') and re-import it in button.tsx, app/page.tsx, and signup-role-picker.tsx. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
`await auth()` was called unguarded in the `app/page.tsx` Server Component. In Clerk test mode (`pk_test_*` keys), Clerk throws when the dev-browser cookie is absent — crashing the page with a 500.
`/login` and `/signup` were unaffected because they are `'use client'` components that never call `auth()` server-side.
Fix
Wrap `auth()` in `try/catch`. If it throws, `role` stays `undefined` and the landing page renders normally. The `redirect()` calls remain outside the try-catch so Next.js's `NEXT_REDIRECT` error still propagates correctly.
Checklist
npm run typecheck— zero errorsnpm run lint— zero errors (3 pre-existing react-hook-form warnings)/will now render the landing page for unauthenticated visitors🤖 Generated with Claude Code