diff --git a/src/components/Feeds/FeedView.tsx b/src/components/Feeds/FeedView.tsx index ed473c431..01661d56c 100644 --- a/src/components/Feeds/FeedView.tsx +++ b/src/components/Feeds/FeedView.tsx @@ -81,7 +81,10 @@ export default function FeedView() { React.useEffect(() => { if (!type || (type === "private" && !isLoggedIn)) { - navigate(`/login?redirectTo=${location.pathname}${location.search}`); + const redirectTo = encodeURIComponent( + `${location.pathname}${location.search}`, + ); + navigate(`/login?redirectTo=${redirectTo}`); } }, [type, navigate, isLoggedIn]); diff --git a/src/components/Login/index.tsx b/src/components/Login/index.tsx index 646cb9067..6b3915534 100644 --- a/src/components/Login/index.tsx +++ b/src/components/Login/index.tsx @@ -77,11 +77,11 @@ export const SimpleLoginPage: React.FunctionComponent = () => { }; if (redirectTo) { - navigate(redirectTo); + const decodedRedirectTo = decodeURIComponent(redirectTo); + navigate(decodedRedirectTo); } else { navigate("/"); } - //redirect(redirectTo); } } catch (error: unknown) { setShowHelperText(true); diff --git a/src/components/PrivateRoute/index.tsx b/src/components/PrivateRoute/index.tsx index 1036cb415..744ac3308 100644 --- a/src/components/PrivateRoute/index.tsx +++ b/src/components/PrivateRoute/index.tsx @@ -4,11 +4,14 @@ import { useTypedSelector } from "../../store/hooks"; const PrivateRoute = ({ children }: { children: JSX.Element }) => { const isLoggedIn = useTypedSelector(({ user }) => user.isLoggedIn); const location = useLocation(); + const redirectTo = encodeURIComponent( + `${location.pathname}${location.search}`, + ); return isLoggedIn ? ( children ) : ( - + ); };