feat: move calculating api base url to store getter
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
kolaente 2021-10-25 22:29:21 +02:00
parent 97e761690d
commit 9a356b2564
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 6 additions and 9 deletions

View File

@ -2,6 +2,7 @@ import {CONFIG} from '../mutation-types'
import {HTTPFactory} from '@/http-common'
import {objectToCamelCase} from '@/helpers/case'
import {redirectToProvider} from '../../helpers/redirectToProvider'
import {parseURL} from 'ufo'
export default {
namespaced: true,
@ -37,6 +38,10 @@ export default {
}),
getters: {
migratorsEnabled: state => state.availableMigrators?.length > 0,
apiBase(state) {
const {host, protocol} = parseURL(window.API_URL)
return protocol + '//' + host
},
},
mutations: {
[CONFIG](state, config) {

View File

@ -41,15 +41,7 @@ export default {
},
computed: {
caldavUrl() {
let apiBase = window.API_URL.replace('/api/v1', '')
if (apiBase === '') { // Frontend and api on the same host which means we need to prefix the frontend url
apiBase = this.$store.state.config.frontendUrl
}
if (apiBase.endsWith('/')) {
apiBase = apiBase.substr(0, apiBase.length - 1)
}
return `${apiBase}/dav/principals/${this.userInfo.username}/`
return `${this.$store.getters['config/apiBase']}/dav/principals/${this.userInfo.username}/`
},
...mapState({
caldavEnabled: state => state.config.caldavEnabled,