Automatically upgrade to HTTPS in production
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
616c063d24
commit
b9fae8e2aa
@ -21,6 +21,14 @@ export class APIClient {
|
|||||||
return URL;
|
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
|
* Perform a request on the backend
|
||||||
*/
|
*/
|
||||||
|
@ -16,9 +16,18 @@ import { DarkThemeProvider } from "./hooks/context_providers/DarkThemeProvider";
|
|||||||
import { SnackbarProvider } from "./hooks/context_providers/SnackbarProvider";
|
import { SnackbarProvider } from "./hooks/context_providers/SnackbarProvider";
|
||||||
import { AsyncWidget } from "./widgets/AsyncWidget";
|
import { AsyncWidget } from "./widgets/AsyncWidget";
|
||||||
import { LoadingMessageProvider } from "./hooks/context_providers/LoadingMessageProvider";
|
import { LoadingMessageProvider } from "./hooks/context_providers/LoadingMessageProvider";
|
||||||
|
import { APIClient } from "./api/ApiClient";
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
try {
|
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(
|
const root = ReactDOM.createRoot(
|
||||||
document.getElementById("root") as HTMLElement
|
document.getElementById("root") as HTMLElement
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user