From 043b67e076b6ec865f0a295d84a8b5a07dabb09d Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 10 Oct 2022 10:12:07 +1100 Subject: [PATCH] Fix setup/migrate redirects on subpath proxies (#2982) --- ui/v2.5/src/App.tsx | 12 +++++++----- ui/v2.5/src/components/Setup/Migrate.tsx | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ui/v2.5/src/App.tsx b/ui/v2.5/src/App.tsx index 2950cd08b..2ab84b1a1 100755 --- a/ui/v2.5/src/App.tsx +++ b/ui/v2.5/src/App.tsx @@ -29,7 +29,7 @@ import { InteractiveProvider } from "./hooks/Interactive/context"; import { ReleaseNotesDialog } from "./components/Dialogs/ReleaseNotesDialog"; import { IUIConfig } from "./core/config"; import { releaseNotes } from "./docs/en/ReleaseNotes"; -import { getPlatformURL } from "./core/createClient"; +import { getPlatformURL, getBaseURL } from "./core/createClient"; const Performers = lazy(() => import("./components/Performers/Performers")); const FrontPage = lazy(() => import("./components/FrontPage/FrontPage")); @@ -121,22 +121,24 @@ export const App: React.FC = () => { return; } + const baseURL = getBaseURL(); + if ( - window.location.pathname !== "/setup" && + window.location.pathname !== baseURL + "setup" && systemStatusData.systemStatus.status === GQL.SystemStatusEnum.Setup ) { // redirect to setup page - const newURL = new URL("/setup", window.location.toString()); + const newURL = new URL("setup", window.location.origin + baseURL); window.location.href = newURL.toString(); } if ( - window.location.pathname !== "/migrate" && + window.location.pathname !== baseURL + "migrate" && systemStatusData.systemStatus.status === GQL.SystemStatusEnum.NeedsMigration ) { // redirect to setup page - const newURL = new URL("/migrate", window.location.toString()); + const newURL = new URL("migrate", window.location.origin + baseURL); window.location.href = newURL.toString(); } }, [systemStatusData]); diff --git a/ui/v2.5/src/components/Setup/Migrate.tsx b/ui/v2.5/src/components/Setup/Migrate.tsx index 3b2226a71..c72625a48 100644 --- a/ui/v2.5/src/components/Setup/Migrate.tsx +++ b/ui/v2.5/src/components/Setup/Migrate.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useMemo, useState } from "react"; import { Button, Card, Container, Form } from "react-bootstrap"; import { useIntl, FormattedMessage } from "react-intl"; +import { getBaseURL } from "src/core/createClient"; import * as GQL from "src/core/generated-graphql"; import { useSystemStatus, mutateMigrate } from "src/core/StashService"; import { migrationNotes } from "src/docs/en/MigrationNotes"; @@ -115,7 +116,7 @@ export const Migrate: React.FC = () => { backupPath: backupPath ?? "", }); - const newURL = new URL("/", window.location.toString()); + const newURL = new URL("", window.location.origin + getBaseURL()); window.location.href = newURL.toString(); } catch (e) { if (e instanceof Error) setMigrateError(e.message ?? e.toString());