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.
This commit is contained in:
parent
0085772b63
commit
c760a9bf72
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue