Skip to content

Commit 680fde5

Browse files
committed
Handle relative and absolute url
1 parent b53bfa2 commit 680fde5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/handleAuth/handleAuth.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,18 @@ const storePostLoginRedirectUrl = (options: Record<string, string | number>) =>
7575
}
7676
};
7777

78+
const isAbsoluteUrl = (url: string) =>
79+
url.indexOf('http://') === 0 || url.indexOf('https://') === 0;
80+
7881
const redirectToPostLoginUrl = () => {
7982
if (sessionStorage.getSessionItem(KEY_POST_LOGIN_REDIRECT_URL)) {
8083
const post_login_redirect_url = sessionStorage.getSessionItem(KEY_POST_LOGIN_REDIRECT_URL);
8184
sessionStorage.removeSessionItem(KEY_POST_LOGIN_REDIRECT_URL);
82-
throw redirect(302, new URL(post_login_redirect_url, kindeConfiguration.appBase));
85+
86+
if (isAbsoluteUrl(post_login_redirect_url)) {
87+
throw redirect(302, new URL(post_login_redirect_url));
88+
} else {
89+
throw redirect(302, new URL(post_login_redirect_url, kindeConfiguration.appBase));
90+
}
8391
}
8492
};

0 commit comments

Comments
 (0)