fix(react-router): Forward redirect URL options from middleware to client state#8622
Conversation
🦋 Changeset detectedLatest commit: c8a291f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors the Clerk React Router middleware to separate redirect URL and keyless URL configuration from the Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Description
When configuring post-auth redirects via environment variables (
CLERK_SIGN_IN_FALLBACK_REDIRECT_URL,CLERK_SIGN_IN_FORCE_REDIRECT_URL, and the sign-up equivalents), users land on a blank page after sign-in or sign-up and must refresh manually.loadOptionsreads all four redirect URL fields from env correctly, andgetResponseClerkStatereferences them when building__internal_clerk_state. ButclerkMiddlewarenever forwarded them togetResponseClerkState, so they serialized asundefinedon the client and theSignIn/SignUpcomponents had no destination after completing auth.This PR reafactors
requestStateContextto carry bothrequestStateand a newadditionalStatebag alongside it, rather than mutating theRequestStateobject returned byauthenticateRequest(which we do not own).additionalStateholds the redirect URL options and keyless URLs.getResponseClerkStatenow accepts these as an explicit parameter instead of reading them off a mutatedrequestState. This mirrors the pattern used in@clerk/tanstack-react-start.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change