Skip to content

Commit

Permalink
BG-1005: Fix /auth-redirector URL appearing after redirecting (#2629)
Browse files Browse the repository at this point in the history
* Reinstall yarn pgks

* Add setTimeout before redirecting in OAUTHRedirector

* Revert yarn.lock
  • Loading branch information
Nenad Misic authored Jan 5, 2024
1 parent 0308804 commit e6f8a08
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/pages/OAuthRedirector.tsx
Original file line number Diff line number Diff line change
@@ -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 <Navigate to={localStorage.getItem(OAUTH_PATH_STORAGE_KEY) ?? "/"} />;
const navigate = useNavigate();

useEffect(() => {
const timeout = setTimeout(
() => navigate(localStorage.getItem(OAUTH_PATH_STORAGE_KEY) ?? "/"),
DELAY
);
return () => {
clearTimeout(timeout);
};
}, [navigate]);

return <h3 className="text-3xl place-self-center p-5">Redirecting...</h3>;
}

0 comments on commit e6f8a08

Please sign in to comment.