diff --git a/src/pages/OAuthRedirector.tsx b/src/pages/OAuthRedirector.tsx index 73dba6c4c7..cb8c1970f9 100644 --- a/src/pages/OAuthRedirector.tsx +++ b/src/pages/OAuthRedirector.tsx @@ -1,6 +1,25 @@ -import { Navigate } from "react-router-dom"; +import { useEffect } from "react"; +import { useNavigate } from "react-router-dom"; import { OAUTH_PATH_STORAGE_KEY } from "constants/auth"; +// For some reason aws-amplify redirects to this page twice; the slowness of the 2nd +// redirect causes the final URL to be of this page even though the rendered page is +// completely different (Marketplace, Register etc.). +// To account for this slowness, we set a timeout and navigate to the desired page afterwards. +const DELAY = 300; + export default function OAUTHRedirector() { - return ; + const navigate = useNavigate(); + + useEffect(() => { + const timeout = setTimeout( + () => navigate(localStorage.getItem(OAUTH_PATH_STORAGE_KEY) ?? "/"), + DELAY + ); + return () => { + clearTimeout(timeout); + }; + }, [navigate]); + + return

Redirecting...

; }