@@ -83,14 +83,14 @@ export async function handleAuth({
83
83
new URL ( request . url ) ,
84
84
) ;
85
85
await redirectToPostLoginUrl ( ) ;
86
- return redirect ( 302 , kindeConfiguration . loginRedirectURL ?? "/" ) ;
86
+ throw redirect ( 302 , kindeConfiguration . loginRedirectURL ?? "/" ) ;
87
87
case "logout" :
88
88
url = await kindeAuthClient . logout ( request as unknown as SessionManager ) ;
89
89
break ;
90
90
default :
91
91
return error ( 404 , "Not Found" ) ;
92
92
}
93
- redirect ( 302 , url . toString ( ) ) ;
93
+ throw redirect ( 302 , url . toString ( ) ) ;
94
94
}
95
95
96
96
const openPortal = async (
@@ -115,7 +115,7 @@ const openPortal = async (
115
115
console . log ( "err:" , err ) ;
116
116
throw error ( 500 , "Failed to generate portal URL" ) ;
117
117
}
118
- redirect ( 302 , portalUrl . url . toString ( ) ) ;
118
+ throw redirect ( 302 , portalUrl . url . toString ( ) ) ;
119
119
} ;
120
120
121
121
const storePostLoginRedirectUrl = (
@@ -136,19 +136,18 @@ const isAbsoluteUrl = (url: string) =>
136
136
url . indexOf ( "http://" ) === 0 || url . indexOf ( "https://" ) === 0 ;
137
137
138
138
const redirectToPostLoginUrl = async ( ) => {
139
- if ( await sessionStorage . getSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ) {
140
- const post_login_redirect_url = ( await sessionStorage . getSessionItem (
141
- KEY_POST_LOGIN_REDIRECT_URL ,
142
- ) ) as string ;
143
- sessionStorage . removeSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ;
139
+ const value = await sessionStorage . getSessionItem (
140
+ KEY_POST_LOGIN_REDIRECT_URL ,
141
+ ) ;
142
+ if ( ! value || typeof value !== "string" ) {
143
+ return ;
144
+ }
145
+ const post_login_redirect_url = value as string ;
146
+ sessionStorage . removeSessionItem ( KEY_POST_LOGIN_REDIRECT_URL ) ;
144
147
145
- if ( isAbsoluteUrl ( post_login_redirect_url ) ) {
146
- redirect ( 302 , new URL ( post_login_redirect_url ) ) ;
147
- } else {
148
- redirect (
149
- 302 ,
150
- new URL ( post_login_redirect_url , kindeConfiguration . appBase ) ,
151
- ) ;
152
- }
148
+ if ( isAbsoluteUrl ( post_login_redirect_url ) ) {
149
+ redirect ( 302 , new URL ( post_login_redirect_url ) ) ;
150
+ } else {
151
+ redirect ( 302 , new URL ( post_login_redirect_url , kindeConfiguration . appBase ) ) ;
153
152
}
154
153
} ;
0 commit comments