@@ -25,7 +25,6 @@ test.describe('Client handshake @generic', () => {
2525 } ) ;
2626 // Strip trailing slash
2727 const devBrowserCookie = '__clerk_db_jwt=needstobeset;' ;
28- const devBrowserQuery = '&__clerk_db_jwt=needstobeset' ;
2928
3029 test . beforeAll ( 'setup local Clerk API mock' , async ( ) => {
3130 const env = appConfigs . envs . withEmailCodes
@@ -367,7 +366,11 @@ test.describe('Client handshake @generic', () => {
367366 } ) ;
368367 expect ( res . status ) . toBe ( 307 ) ;
369368 const locationUrl = new URL ( res . headers . get ( 'location' ) ) ;
370- expect ( locationUrl . origin + locationUrl . pathname ) . toBe ( 'https://clerk.example.com/v1/client/handshake' ) ;
369+
370+ // The domain is ignored for non-satellite requests
371+ expect ( locationUrl . hostname ) . not . toBe ( 'example.com' ) ;
372+
373+ expect ( locationUrl . origin + locationUrl . pathname ) . toContain ( '/v1/client/handshake' ) ;
371374 expect ( locationUrl . searchParams . get ( 'redirect_url' ) ) . toBe ( `${ app . serverUrl } /` ) ;
372375 expect ( locationUrl . searchParams . get ( '__clerk_hs_reason' ) ) . toBe (
373376 'session-token-expired-refresh-non-eligible-no-refresh-cookie' ,
@@ -376,6 +379,30 @@ test.describe('Client handshake @generic', () => {
376379 expect ( locationUrl . searchParams . get ( 'suffixed_cookies' ) ) . toBe ( 'false' ) ;
377380 } ) ;
378381
382+ test ( 'domain - prod satellite - domain is used as the redirect url' , async ( ) => {
383+ const config = generateConfig ( {
384+ mode : 'live' ,
385+ } ) ;
386+ const { token, claims } = config . generateToken ( { state : 'expired' } ) ;
387+ const clientUat = claims . iat ;
388+ const res = await fetch ( app . serverUrl + '/' , {
389+ headers : new Headers ( {
390+ Cookie : `__client_uat=${ clientUat } ; __session=${ token } ` ,
391+ 'X-Publishable-Key' : config . pk ,
392+ 'X-Secret-Key' : config . sk ,
393+ 'X-Satellite' : 'true' ,
394+ 'X-Domain' : 'example.com' ,
395+ 'Sec-Fetch-Dest' : 'document' ,
396+ } ) ,
397+ redirect : 'manual' ,
398+ } ) ;
399+ expect ( res . status ) . toBe ( 307 ) ;
400+ const locationUrl = new URL ( res . headers . get ( 'location' ) ) ;
401+
402+ // The domain is used as the redirect url
403+ expect ( locationUrl . origin + locationUrl . pathname ) . toBe ( 'https://clerk.example.com/v1/client/handshake' ) ;
404+ } ) ;
405+
379406 test ( 'missing session token, positive uat - dev' , async ( ) => {
380407 const config = generateConfig ( {
381408 mode : 'test' ,
0 commit comments