Skip to content

Commit c634bb7

Browse files
author
Alexis
committed
fix: more throw redirects, and fix redirectToPostLogin so if not absolute url, it will return and redirect to login
1 parent fee7503 commit c634bb7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib/handleAuth/handleAuth.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,13 @@ const redirectToPostLoginUrl = async () => {
145145
const post_login_redirect_url = value as string;
146146
sessionStorage.removeSessionItem(KEY_POST_LOGIN_REDIRECT_URL);
147147

148+
const appBaseUrl = new URL(kindeConfiguration.appBase);
148149
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));
150+
const target = new URL(post_login_redirect_url);
151+
if (target.origin !== appBaseUrl.origin) {
152+
return;
153+
}
154+
throw redirect(302, target.toString());
152155
}
156+
throw redirect(302, new URL(post_login_redirect_url, appBaseUrl).toString());
153157
};

0 commit comments

Comments
 (0)