From 1781318fdfea7600014c8162bdf46de18143365f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 3 Jul 2025 22:00:20 +0200 Subject: [PATCH] Fix bad backend URL on generated Qr Code for tokens authentication --- moneymgr_web/src/api/ApiClient.ts | 11 ++++++++++- moneymgr_web/src/routes/TokensRoute.tsx | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/moneymgr_web/src/api/ApiClient.ts b/moneymgr_web/src/api/ApiClient.ts index d8c7c5f..feab1e8 100644 --- a/moneymgr_web/src/api/ApiClient.ts +++ b/moneymgr_web/src/api/ApiClient.ts @@ -31,12 +31,21 @@ export class APIClient { return URL; } + /** + * Get the full URL at which the backend can be contacted + */ + static ActualBackendURL(): string { + const backendURL = this.backendURL(); + if (backendURL.startsWith("/")) return `${location.origin}${backendURL}`; + else return backendURL; + } + /** * Check out whether the backend is accessed through * HTTPS or not */ static IsBackendSecure(): boolean { - return this.backendURL().startsWith("https"); + return this.ActualBackendURL().startsWith("https"); } /** diff --git a/moneymgr_web/src/routes/TokensRoute.tsx b/moneymgr_web/src/routes/TokensRoute.tsx index 32bed73..fb9ef51 100644 --- a/moneymgr_web/src/routes/TokensRoute.tsx +++ b/moneymgr_web/src/routes/TokensRoute.tsx @@ -268,7 +268,7 @@ function CreatedToken(p: { token: TokenWithSecret }): React.ReactElement {