Skip to content

Commit

Permalink
fix(tanstack-start): Merge router context instead of updating (#4425)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Wright <[email protected]>
  • Loading branch information
octoper and jeremy-clerk authored Oct 30, 2024
1 parent a06f1f3 commit 915b257
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-moose-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/tanstack-start": patch
---

- Fixes a bug where the initial router context is getting overwritten when updating the router inside `createClerkHandler`
6 changes: 2 additions & 4 deletions packages/tanstack-start/src/server/middlewareHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ export function createClerkHandler<TRouter extends AnyRouter>(

const clerkInitialState = getResponseClerkState(requestState, loadedOptions);

// Updating the TanStack router context with the Clerk context and loading the router
// Merging the TanStack router context with the Clerk context and loading the router
router.update({
context: clerkInitialState,
context: { ...router.options.context, ...clerkInitialState },
});

await router.load();
} catch (error) {
if (error instanceof Response) {
// returning the response
Expand Down

0 comments on commit 915b257

Please sign in to comment.