@@ -511,26 +511,39 @@ describe('isAllowedRedirect', () => {
511511} ) ;
512512
513513describe ( 'createAllowedRedirectOrigins' , ( ) => {
514- it ( 'contains the default allowed origin values if no value is provided' , async ( ) => {
515- const frontendApi = 'https://somename.clerk.accounts.dev' ;
516- const allowedRedirectOriginsValuesUndefined = createAllowedRedirectOrigins ( undefined , frontendApi ) ;
517- const allowedRedirectOriginsValuesEmptyArray = createAllowedRedirectOrigins ( [ ] , frontendApi ) ;
518-
519- expect ( allowedRedirectOriginsValuesUndefined ) . toEqual ( [
520- 'http://localhost' ,
521- `https://${ getETLDPlusOneFromFrontendApi ( frontendApi ) } ` ,
522- `https://*.${ getETLDPlusOneFromFrontendApi ( frontendApi ) } ` ,
523- ] ) ;
524-
525- expect ( allowedRedirectOriginsValuesEmptyArray ) . toEqual ( [
526- 'http://localhost' ,
527- `https://${ getETLDPlusOneFromFrontendApi ( frontendApi ) } ` ,
528- `https://*.${ getETLDPlusOneFromFrontendApi ( frontendApi ) } ` ,
529- ] ) ;
514+ it ( 'contains the default allowed origin values if no value is provided when production instance' , ( ) => {
515+ const frontendApi = 'clerk.example.com' ;
516+ const allowedRedirectOriginsValuesUndefined = createAllowedRedirectOrigins ( undefined , frontendApi , 'production' ) ;
517+ const allowedRedirectOriginsValuesEmptyArray = createAllowedRedirectOrigins ( [ ] , frontendApi , 'production' ) ;
518+
519+ const expectedAllowedRedirectOrigins = [
520+ 'http://localhost' , // Current location
521+ `https://example.com` , // Primary domain
522+ `https://*.example.com` , // Wildcard subdomains
523+ ] ;
524+
525+ expect ( allowedRedirectOriginsValuesUndefined ) . toEqual ( expectedAllowedRedirectOrigins ) ;
526+ expect ( allowedRedirectOriginsValuesEmptyArray ) . toEqual ( expectedAllowedRedirectOrigins ) ;
527+ } ) ;
528+
529+ it ( 'contains the default allowed origin values and FAPI if no value is provided when development instance' , ( ) => {
530+ const frontendApi = 'foo-bar-42.clerk.accounts.dev' ;
531+ const allowedRedirectOriginsValuesUndefined = createAllowedRedirectOrigins ( undefined , frontendApi , 'development' ) ;
532+ const allowedRedirectOriginsValuesEmptyArray = createAllowedRedirectOrigins ( [ ] , frontendApi , 'development' ) ;
533+
534+ const expectedAllowedRedirectOrigins = [
535+ 'http://localhost' , // Current location
536+ `https://foo-bar-42.accounts.dev` , // Account Portal
537+ `https://*.foo-bar-42.accounts.dev` , // Account Portal subdomains
538+ `https://foo-bar-42.clerk.accounts.dev` , // Frontend API
539+ ] ;
540+
541+ expect ( allowedRedirectOriginsValuesUndefined ) . toEqual ( expectedAllowedRedirectOrigins ) ;
542+ expect ( allowedRedirectOriginsValuesEmptyArray ) . toEqual ( expectedAllowedRedirectOrigins ) ;
530543 } ) ;
531544
532545 it ( 'contains only the allowedRedirectOrigins options given' , async ( ) => {
533- const frontendApi = 'https:// somename.clerk.accounts.dev' ;
546+ const frontendApi = 'somename.clerk.accounts.dev' ;
534547 const allowedRedirectOriginsValues = createAllowedRedirectOrigins (
535548 [ 'https://test.host' , 'https://*.test.host' ] ,
536549 frontendApi ,
0 commit comments