From c760a9bf72360a2cc2ade10277e800d76986bd2a Mon Sep 17 00:00:00 2001 From: MidoriKurage Date: Sat, 21 Mar 2026 23:24:16 +0800 Subject: [PATCH] fix(caldav): Replace href with pathname from parseURL for api base `parseURL` only return `href` for special protocols. CalDAV api base will always be root path. Use `pathname` which will not be undefined. --- frontend/src/stores/config.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/src/stores/config.ts b/frontend/src/stores/config.ts index e5f70d54f..40f47a4c0 100644 --- a/frontend/src/stores/config.ts +++ b/frontend/src/stores/config.ts @@ -87,12 +87,13 @@ export const useConfigStore = defineStore('config', () => { const migratorsEnabled = computed(() => state.availableMigrators?.length > 0) const apiBase = computed(() => { - const {host, protocol, href} = parseURL(window.API_URL) + const {host, protocol, pathname} = parseURL(window.API_URL) - const cleanHref = href ? (href.endsWith('/') - ? href.slice(0, -1) - : href) : '' - return `${protocol}//${host}${cleanHref ? `/${cleanHref}` : ''}` + // Strip the /api/v1 suffix (and optional trailing slash) to get the deployment base. + const basePath = pathname + .replace(/\/api\/v1\/?$/, '') + .replace(/\/+$/, '') + return `${protocol}//${host}${basePath}` }) function setConfig(config: ConfigState) {