From 63bd0a649f2b2741eef29715ca859dd7c37d5d6a Mon Sep 17 00:00:00 2001 From: Stephen Pegoraro Date: Mon, 24 Nov 2025 13:54:36 +1100 Subject: [PATCH 1/2] pass options from clerkMiddleware to clerkClient --- packages/react-router/src/server/clerkClient.ts | 5 +++-- packages/react-router/src/server/clerkMiddleware.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-router/src/server/clerkClient.ts b/packages/react-router/src/server/clerkClient.ts index 3c52229da3b..b37254c579d 100644 --- a/packages/react-router/src/server/clerkClient.ts +++ b/packages/react-router/src/server/clerkClient.ts @@ -1,9 +1,10 @@ import { createClerkClient } from '@clerk/backend'; import { type DataFunctionArgs, loadOptions } from './loadOptions'; +import type { ClerkMiddlewareOptions } from './types'; -export const clerkClient = (args: DataFunctionArgs) => { - const options = loadOptions(args); +export const clerkClient = (args: DataFunctionArgs, overrides: ClerkMiddlewareOptions = {}) => { + const options = loadOptions(args, overrides); const { apiUrl, secretKey, jwtKey, proxyUrl, isSatellite, domain, publishableKey, machineSecretKey } = options; diff --git a/packages/react-router/src/server/clerkMiddleware.ts b/packages/react-router/src/server/clerkMiddleware.ts index af71c526097..147f42dc699 100644 --- a/packages/react-router/src/server/clerkMiddleware.ts +++ b/packages/react-router/src/server/clerkMiddleware.ts @@ -55,7 +55,7 @@ export const clerkMiddleware = (options?: ClerkMiddlewareOptions): MiddlewareFun organizationSyncOptions, } = loadedOptions; - const requestState = await clerkClient(args).authenticateRequest(clerkRequest, { + const requestState = await clerkClient(args, options).authenticateRequest(clerkRequest, { apiUrl, secretKey, jwtKey, From 71ba3eb025d261427e102e98c7089e6b3a3805cb Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Mon, 24 Nov 2025 09:04:26 -0800 Subject: [PATCH 2/2] chore: add changeset --- .changeset/khaki-cows-sell.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-cows-sell.md diff --git a/.changeset/khaki-cows-sell.md b/.changeset/khaki-cows-sell.md new file mode 100644 index 00000000000..92c30ca1bcd --- /dev/null +++ b/.changeset/khaki-cows-sell.md @@ -0,0 +1,5 @@ +--- +'@clerk/react-router': minor +--- + +Options passed to `clerkMiddleware` are now properly forwarded to `clerkClient`, ensuring consistent configuration when manually providing options from router context.