diff --git a/geneit_app/src/api/ApiClient.ts b/geneit_app/src/api/ApiClient.ts index 8bfd22c..8514fd0 100644 --- a/geneit_app/src/api/ApiClient.ts +++ b/geneit_app/src/api/ApiClient.ts @@ -21,6 +21,14 @@ export class APIClient { return URL; } + /** + * Check out whether the backend is accessed through + * HTTPS or not + */ + static IsBackendSecure(): boolean { + return this.backendURL().startsWith("https"); + } + /** * Perform a request on the backend */ diff --git a/geneit_app/src/index.tsx b/geneit_app/src/index.tsx index 10e804b..2c958df 100644 --- a/geneit_app/src/index.tsx +++ b/geneit_app/src/index.tsx @@ -16,9 +16,18 @@ import { DarkThemeProvider } from "./hooks/context_providers/DarkThemeProvider"; import { SnackbarProvider } from "./hooks/context_providers/SnackbarProvider"; import { AsyncWidget } from "./widgets/AsyncWidget"; import { LoadingMessageProvider } from "./hooks/context_providers/LoadingMessageProvider"; +import { APIClient } from "./api/ApiClient"; async function init() { try { + if ( + APIClient.IsBackendSecure() && + !window.location.href.startsWith("https") && + window.location.hostname !== "localhost" + ) { + window.location.href = window.location.href.replace("http:", "https:"); + } + const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement );