Fix logout/login redirects in subpath deployments (#46715)

Fixes #46639

Hard-coded "/" and "/login" strings bypassed the URL prefix when Fleet
is deployed behind a reverse proxy at a subpath. Replaced with
PATHS.ROOT / PATHS.LOGIN, which embed URL_PREFIX, so redirects now land
at the correct subpath.
This commit is contained in:
Juan Fernandez
2026-06-03 10:12:48 -04:00
committed by GitHub
parent d246865a2a
commit ad4ef6c309
5 changed files with 8 additions and 5 deletions
@@ -0,0 +1 @@
* Fixed logout/login redirects to respect the URL prefix in subpath deployments.
+2 -1
View File
@@ -4,6 +4,7 @@ import { useQuery } from "react-query";
import { ErrorBoundary } from "react-error-boundary";
import { isBefore } from "date-fns";
import PATHS from "router/paths";
import page_titles from "router/page_titles";
import TableProvider from "context/table";
import QueryProvider from "context/query";
@@ -210,7 +211,7 @@ const App = ({ children, location }: IAppProps): JSX.Element => {
// if this is not the device user page,
// redirect to login
if (!location?.pathname.includes("/device/")) {
window.location.href = "/login";
window.location.href = PATHS.LOGIN;
}
}
return true;
+2 -1
View File
@@ -1,6 +1,7 @@
import { useContext, useEffect } from "react";
import { InjectedRouter } from "react-router";
import PATHS from "router/paths";
import { AppContext } from "context/app";
import { NotificationContext } from "context/notification";
import sessionsAPI from "services/entities/sessions";
@@ -22,7 +23,7 @@ const LogoutPage = ({ router }: ILogoutPageProps) => {
setTimeout(() => {
window.location.href = isSandboxMode
? "https://www.fleetdm.com/logout"
: "/";
: PATHS.ROOT;
}, 500);
} catch (response) {
console.error(response);
@@ -150,7 +150,7 @@ const UsersPage = ({ location, router }: ITeamSubnavProps): JSX.Element => {
);
// If user removes self from team, redirect to home
if (currentUser && currentUser.id === removedUsers.users[0].id) {
window.location.href = "/";
window.location.href = PATHS.ROOT;
}
})
.catch(() =>
@@ -319,7 +319,7 @@ const UsersPage = ({ location, router }: ITeamSubnavProps): JSX.Element => {
(thisTeam) => thisTeam.id === teamIdForApi
);
if (selectedTeam && selectedTeam[0].role !== "admin") {
window.location.href = "/";
window.location.href = PATHS.ROOT;
}
} else {
refetchUsers();
@@ -218,7 +218,7 @@ const UsersTable = ({ router }: IUsersTableProps): JSX.Element => {
if (isResettingCurrentUser) {
authToken.remove();
setTimeout(() => {
window.location.href = "/";
window.location.href = PATHS.ROOT;
}, 500);
return;
}