From 02ba37fab4bedd0ce0a2e8b27cef4b4edb4f5a85 Mon Sep 17 00:00:00 2001 From: josc146 Date: Wed, 8 Nov 2023 22:25:41 +0800 Subject: [PATCH] improve api url getter --- frontend/src/utils/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx index 3148e51..a77b7c1 100644 --- a/frontend/src/utils/index.tsx +++ b/frontend/src/utils/index.tsx @@ -290,8 +290,9 @@ export function bytesToReadable(size: number) { } export function getServerRoot(defaultLocalPort: number) { - if (commonStore.settings.apiUrl) - return commonStore.settings.apiUrl; + const customApiUrl = commonStore.settings.apiUrl.trim().replace(/\/$/, ''); + if (customApiUrl) + return customApiUrl; if (commonStore.platform === 'web') return ''; return `http://127.0.0.1:${defaultLocalPort}`;