diff --git a/frontend/src/component/App.tsx b/frontend/src/component/App.tsx
index 56cd5c8625..3b2094721d 100644
--- a/frontend/src/component/App.tsx
+++ b/frontend/src/component/App.tsx
@@ -87,6 +87,7 @@ export const App = () => {
path="/"
unauthorized={isUnauthorized()}
component={Redirect}
+ renderProps={{ to: '/features' }}
/>
{renderMainLayoutRoutes()}
{renderStandaloneRoutes()}
diff --git a/frontend/src/component/common/ProtectedRoute/ProtectedRoute.jsx b/frontend/src/component/common/ProtectedRoute/ProtectedRoute.jsx
index 7c26fda618..2ab6d65e4c 100644
--- a/frontend/src/component/common/ProtectedRoute/ProtectedRoute.jsx
+++ b/frontend/src/component/common/ProtectedRoute/ProtectedRoute.jsx
@@ -1,4 +1,4 @@
-import { Route, useLocation, useHistory } from 'react-router-dom';
+import { Route, useLocation, Redirect } from 'react-router-dom';
const ProtectedRoute = ({
component: Component,
@@ -7,7 +7,6 @@ const ProtectedRoute = ({
...rest
}) => {
const { pathname } = useLocation();
- const history = useHistory();
const loginLink =
pathname.length > 1 ? `/login?redirect=${pathname}` : '/login';
return (
@@ -15,7 +14,7 @@ const ProtectedRoute = ({
{...rest}
render={props => {
if (unauthorized) {
- history.push(loginLink);
+ return ;
} else {
return ;
}
diff --git a/frontend/src/component/user/DemoAuth/DemoAuth.jsx b/frontend/src/component/user/DemoAuth/DemoAuth.jsx
index 550b0ea4d7..74ae506a00 100644
--- a/frontend/src/component/user/DemoAuth/DemoAuth.jsx
+++ b/frontend/src/component/user/DemoAuth/DemoAuth.jsx
@@ -90,6 +90,7 @@ const DemoAuth = ({ authDetails, redirect }) => {
DemoAuth.propTypes = {
authDetails: PropTypes.object.isRequired,
+ redirect: PropTypes.string.isRequired,
};
export default DemoAuth;
diff --git a/frontend/src/component/user/Login/Login.tsx b/frontend/src/component/user/Login/Login.tsx
index 03ef1bcb25..c346737ad9 100644
--- a/frontend/src/component/user/Login/Login.tsx
+++ b/frontend/src/component/user/Login/Login.tsx
@@ -7,7 +7,7 @@ import { DEMO_TYPE } from '../../../constants/authTypes';
import Authentication from '../Authentication/Authentication';
import { useAuthDetails } from '../../../hooks/api/getters/useAuth/useAuthDetails';
import { useAuthUser } from '../../../hooks/api/getters/useAuth/useAuthUser';
-import { useHistory } from 'react-router-dom';
+import { Redirect, useHistory } from 'react-router-dom';
const Login = () => {
const styles = useStyles();
@@ -15,11 +15,10 @@ const Login = () => {
const { user } = useAuthUser();
const query = useQueryParams();
const resetPassword = query.get('reset') === 'true';
- const redirect = query.get('redirect') || '/features';
- const history = useHistory();
+ const redirect = query.get('redirect') || '/';
if (user) {
- history.replace(redirect);
+ return ;
}
return (