File tree Expand file tree Collapse file tree 5 files changed +17
-7
lines changed Expand file tree Collapse file tree 5 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import useApi from "./screens/Console/Common/Hooks/useApi";
3232import { ErrorResponseHandler } from "./common/types" ;
3333import { ReplicationSite } from "./screens/Console/Configurations/SiteReplication/SiteReplication" ;
3434import { SRInfoStateType } from "./types" ;
35+ import { baseUrl } from "./history" ;
3536
3637interface ProtectedRouteProps {
3738 loggedIn : boolean ;
@@ -113,7 +114,11 @@ const ProtectedRoute = ({
113114 return null ;
114115 }
115116 // redirect user to the right page based on session status
116- return loggedIn ? < Component /> : < Redirect to = { { pathname : "login" } } /> ;
117+ return loggedIn ? (
118+ < Component />
119+ ) : (
120+ < Redirect to = { { pathname : `${ baseUrl } login` } } />
121+ ) ;
117122} ;
118123
119124const mapState = ( state : AppState ) => ( {
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import request from "superagent";
1818import get from "lodash/get" ;
1919import { clearSession } from "../utils" ;
2020import { ErrorResponseHandler } from "../types" ;
21+ import { baseUrl } from "../../history" ;
2122
2223export class API {
2324 invoke ( method : string , url : string , data ?: object ) {
@@ -37,7 +38,7 @@ export class API {
3738 clearSession ( ) ;
3839 // Refresh the whole page to ensure cache is clear
3940 // and we dont end on an infinite loop
40- window . location . href = " login" ;
41+ window . location . href = ` ${ baseUrl } login` ;
4142 return ;
4243 }
4344 return this . onError ( err ) ;
@@ -71,7 +72,7 @@ export class API {
7172 return Promise . reject ( throwMessage ) ;
7273 } else {
7374 clearSession ( ) ;
74- window . location . href = " login" ;
75+ window . location . href = ` ${ baseUrl } login` ;
7576 }
7677 }
7778}
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import { BrowserHistoryBuildOptions } from "history/createBrowserHistory";
44let browserHistoryOpts : BrowserHistoryBuildOptions = { } ;
55
66let basename = document . baseURI . replace ( window . location . origin , "" ) ;
7+ // check if we are using base path, if not this always is `/`
8+ const baseLocation = new URL ( document . baseURI ) ;
9+ export const baseUrl = baseLocation . pathname ;
710
811if ( basename !== "" ) {
912 browserHistoryOpts . basename = basename ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import { setMenuOpen, userLoggedIn } from "../../../actions";
2727import { ErrorResponseHandler } from "../../../common/types" ;
2828import { clearSession } from "../../../common/utils" ;
2929
30- import history from "../../../history" ;
30+ import history , { baseUrl } from "../../../history" ;
3131import api from "../../../common/api" ;
3232
3333import { resetSession } from "../actions" ;
@@ -106,8 +106,9 @@ const Menu = ({
106106 clearSession ( ) ;
107107 userLoggedIn ( false ) ;
108108 localStorage . setItem ( "userLoggedIn" , "" ) ;
109+ localStorage . setItem ( "redirect-path" , "" ) ;
109110 resetSession ( ) ;
110- history . push ( " login" ) ;
111+ history . push ( ` ${ baseUrl } login` ) ;
111112 } ;
112113 api
113114 . invoke ( "POST" , `/api/v1/logout` )
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ import api from "../../common/api";
1919import withStyles from "@mui/styles/withStyles" ;
2020import { Theme } from "@mui/material/styles" ;
2121import createStyles from "@mui/styles/createStyles" ;
22- import history from "../../history" ;
22+ import history , { baseUrl } from "../../history" ;
2323import { Paper } from "@mui/material" ;
2424import Grid from "@mui/material/Grid" ;
2525import Typography from "@mui/material/Typography" ;
@@ -175,7 +175,7 @@ const LoginCallback = ({ classes }: ILoginCallBackProps) => {
175175 </ Typography >
176176 < Button
177177 component = { "a" }
178- href = " login"
178+ href = { ` ${ baseUrl } login` }
179179 type = "submit"
180180 variant = "contained"
181181 color = "primary"
You can’t perform that action at this time.
0 commit comments