@@ -21,6 +21,13 @@ const fapiClientWithProxy = createFapiClient({
2121 proxyUrl,
2222} ) ;
2323
24+ const proxyUrlWithTrailingSlash = 'https://clerk.com/api/__clerk/' ;
25+
26+ const fapiClientWithProxyTrailingSlash = createFapiClient ( {
27+ ...baseFapiClientOptions ,
28+ proxyUrl : proxyUrlWithTrailingSlash ,
29+ } ) ;
30+
2431type RecursivePartial < T > = {
2532 [ P in keyof T ] ?: RecursivePartial < T [ P ] > ;
2633} ;
@@ -79,6 +86,20 @@ describe('buildUrl(options)', () => {
7986 ) ;
8087 } ) ;
8188
89+ it ( 'returns the correct URL when proxy URL has a trailing slash' , ( ) => {
90+ // The expected URL should NOT have double slashes after __clerk
91+ expect ( fapiClientWithProxyTrailingSlash . buildUrl ( { path : '/foo' } ) . href ) . toBe (
92+ `https://clerk.com/api/__clerk/v1/foo?__clerk_api_version=${ SUPPORTED_FAPI_VERSION } &_clerk_js_version=test` ,
93+ ) ;
94+ } ) ;
95+
96+ it ( 'handles complex paths correctly with proxy URL with trailing slash' , ( ) => {
97+ const path = '/client/sign_ins/sia_123/prepare_first_factor' ;
98+ expect ( fapiClientWithProxyTrailingSlash . buildUrl ( { path } ) . href ) . toBe (
99+ `https://clerk.com/api/__clerk/v1${ path } ?__clerk_api_version=${ SUPPORTED_FAPI_VERSION } &_clerk_js_version=test` ,
100+ ) ;
101+ } ) ;
102+
82103 it ( 'uses domain from options if production' , ( ) => {
83104 expect (
84105 createFapiClient ( { ...baseFapiClientOptions , domain : 'clerk.other.com' , instanceType : 'production' } ) . buildUrl ( {
0 commit comments