diff --git a/src/components/misc/ready.vue b/src/components/misc/ready.vue index 0dcec830e..f069dbfa4 100644 --- a/src/components/misc/ready.vue +++ b/src/components/misc/ready.vue @@ -44,8 +44,7 @@ import ApiConfig from '@/components/misc/api-config' import NoAuthWrapper from '@/components/misc/no-auth-wrapper' import {mapState} from 'vuex' import {ONLINE} from '@/store/mutation-types' - -const ERROR_NO_API_URL = 'noApiUrlProvided' +import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl' export default { name: 'ready', @@ -76,11 +75,6 @@ export default { }, methods: { load() { - if (window.API_URL === '') { - this.error = ERROR_NO_API_URL - return - } - this.$store.dispatch('loadApp') .catch(e => { this.error = e diff --git a/src/helpers/checkAndSetApiUrl.ts b/src/helpers/checkAndSetApiUrl.ts index 8cab0f73f..166271c72 100644 --- a/src/helpers/checkAndSetApiUrl.ts +++ b/src/helpers/checkAndSetApiUrl.ts @@ -1,5 +1,7 @@ const API_DEFAULT_PORT = '3456' +export const ERROR_NO_API_URL = 'noApiUrlProvided' + export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise): Promise => { // Check if the url has an http prefix if ( @@ -106,6 +108,7 @@ export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise localStorage.setItem('API_URL', window.API_URL) return window.API_URL } - return '' + + throw new Error(ERROR_NO_API_URL) }) }