Fix setup/migrate redirects on subpath proxies (#2982)

This commit is contained in:
WithoutPants
2022-10-10 10:12:07 +11:00
committed by GitHub
parent 6c04f9199f
commit 043b67e076
2 changed files with 9 additions and 6 deletions

View File

@@ -29,7 +29,7 @@ import { InteractiveProvider } from "./hooks/Interactive/context";
import { ReleaseNotesDialog } from "./components/Dialogs/ReleaseNotesDialog"; import { ReleaseNotesDialog } from "./components/Dialogs/ReleaseNotesDialog";
import { IUIConfig } from "./core/config"; import { IUIConfig } from "./core/config";
import { releaseNotes } from "./docs/en/ReleaseNotes"; 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 Performers = lazy(() => import("./components/Performers/Performers"));
const FrontPage = lazy(() => import("./components/FrontPage/FrontPage")); const FrontPage = lazy(() => import("./components/FrontPage/FrontPage"));
@@ -121,22 +121,24 @@ export const App: React.FC = () => {
return; return;
} }
const baseURL = getBaseURL();
if ( if (
window.location.pathname !== "/setup" && window.location.pathname !== baseURL + "setup" &&
systemStatusData.systemStatus.status === GQL.SystemStatusEnum.Setup systemStatusData.systemStatus.status === GQL.SystemStatusEnum.Setup
) { ) {
// redirect to setup page // 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(); window.location.href = newURL.toString();
} }
if ( if (
window.location.pathname !== "/migrate" && window.location.pathname !== baseURL + "migrate" &&
systemStatusData.systemStatus.status === systemStatusData.systemStatus.status ===
GQL.SystemStatusEnum.NeedsMigration GQL.SystemStatusEnum.NeedsMigration
) { ) {
// redirect to setup page // 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(); window.location.href = newURL.toString();
} }
}, [systemStatusData]); }, [systemStatusData]);

View File

@@ -1,6 +1,7 @@
import React, { useEffect, useMemo, useState } from "react"; import React, { useEffect, useMemo, useState } from "react";
import { Button, Card, Container, Form } from "react-bootstrap"; import { Button, Card, Container, Form } from "react-bootstrap";
import { useIntl, FormattedMessage } from "react-intl"; import { useIntl, FormattedMessage } from "react-intl";
import { getBaseURL } from "src/core/createClient";
import * as GQL from "src/core/generated-graphql"; import * as GQL from "src/core/generated-graphql";
import { useSystemStatus, mutateMigrate } from "src/core/StashService"; import { useSystemStatus, mutateMigrate } from "src/core/StashService";
import { migrationNotes } from "src/docs/en/MigrationNotes"; import { migrationNotes } from "src/docs/en/MigrationNotes";
@@ -115,7 +116,7 @@ export const Migrate: React.FC = () => {
backupPath: backupPath ?? "", backupPath: backupPath ?? "",
}); });
const newURL = new URL("/", window.location.toString()); const newURL = new URL("", window.location.origin + getBaseURL());
window.location.href = newURL.toString(); window.location.href = newURL.toString();
} catch (e) { } catch (e) {
if (e instanceof Error) setMigrateError(e.message ?? e.toString()); if (e instanceof Error) setMigrateError(e.message ?? e.toString());