Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tanstack-start): Merge router context instead of updating #4425

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading