Skip to content
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/proud-carrots-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Exclude `_clerk_session_id` query param from `/waitlist` endpoint
5 changes: 4 additions & 1 deletion packages/clerk-js/src/core/__tests__/fapiClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ describe('buildUrl(options)', () => {
);
});

it('adds _clerk_session_id as a query parameter if provided and path does not start with client', () => {
it('adds _clerk_session_id as a query parameter if provided and path does not start with client or waitlist', () => {
expect(fapiClient.buildUrl({ path: '/foo', sessionId: 'sess_42' }).href).toBe(
`https://clerk.example.com/v1/foo?__clerk_api_version=${SUPPORTED_FAPI_VERSION}&_clerk_js_version=42.0.0&_clerk_session_id=sess_42`,
);
expect(fapiClient.buildUrl({ path: '/client/foo', sessionId: 'sess_42' }).href).toBe(
`https://clerk.example.com/v1/client/foo?__clerk_api_version=${SUPPORTED_FAPI_VERSION}&_clerk_js_version=42.0.0`,
);
expect(fapiClient.buildUrl({ path: '/waitlist', sessionId: 'sess_42' }).href).toBe(
`https://clerk.example.com/v1/waitlist?__clerk_api_version=${SUPPORTED_FAPI_VERSION}&_clerk_js_version=42.0.0`,
);
});

it('parses search params is an object with string values', () => {
Expand Down
5 changes: 4 additions & 1 deletion packages/clerk-js/src/core/fapiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export interface FapiClient {
request<T>(requestInit: FapiRequestInit): Promise<FapiResponse<T>>;
}

// List of paths that should not receive the session ID parameter in the URL
const unauthorizedPathPrefixes = ['/client', '/waitlist'];

export function createFapiClient(clerkInstance: Clerk): FapiClient {
const onBeforeRequestCallbacks: Array<FapiRequestCallback<unknown>> = [];
const onAfterResponseCallbacks: Array<FapiRequestCallback<unknown>> = [];
Expand Down Expand Up @@ -116,7 +119,7 @@ export function createFapiClient(clerkInstance: Clerk): FapiClient {
searchParams.append('_method', method);
}

if (path && !path.startsWith('/client') && sessionId) {
if (path && !unauthorizedPathPrefixes.some(p => path.startsWith(p)) && sessionId) {
searchParams.append('_clerk_session_id', sessionId);
}

Expand Down