From dac21ed7ba585549a1e981902f0fe66d90fb4ba5 Mon Sep 17 00:00:00 2001 From: Vaggelis Yfantis Date: Wed, 30 Oct 2024 11:23:56 +0200 Subject: [PATCH] Revert "fix(tanstack-start): Merge router context instead of updating (#4425)" This reverts commit 915b2579a1d83941cd2b9b5708a3eb519ced53d7. --- .changeset/silly-moose-tease.md | 5 ----- packages/tanstack-start/src/server/middlewareHandler.ts | 6 ++++-- 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 .changeset/silly-moose-tease.md diff --git a/.changeset/silly-moose-tease.md b/.changeset/silly-moose-tease.md deleted file mode 100644 index 9663160bbfe..00000000000 --- a/.changeset/silly-moose-tease.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@clerk/tanstack-start": patch ---- - -- Fixes a bug where the initial router context is getting overwritten when updating the router inside `createClerkHandler` diff --git a/packages/tanstack-start/src/server/middlewareHandler.ts b/packages/tanstack-start/src/server/middlewareHandler.ts index 1eaaf936219..707087ad027 100644 --- a/packages/tanstack-start/src/server/middlewareHandler.ts +++ b/packages/tanstack-start/src/server/middlewareHandler.ts @@ -26,10 +26,12 @@ export function createClerkHandler( const clerkInitialState = getResponseClerkState(requestState, loadedOptions); - // Merging the TanStack router context with the Clerk context and loading the router + // Updating the TanStack router context with the Clerk context and loading the router router.update({ - context: { ...router.options.context, ...clerkInitialState }, + context: clerkInitialState, }); + + await router.load(); } catch (error) { if (error instanceof Response) { // returning the response