diff --git a/composables/api.ts b/composables/api.ts index f7ce12d..d5cf56a 100644 --- a/composables/api.ts +++ b/composables/api.ts @@ -1,11 +1,14 @@ import type { FetchError } from 'ofetch' -const apiEndpoint = - 'https://' + - (process.dev - ? useRuntimeConfig().public.apiIp || window.location.hostname - : window.location.hostname) + - '/yunohost/portalapi' +const useApiEndpoint = () => { + return ( + 'https://' + + (process.dev + ? useRuntimeConfig().public.apiIp || window.location.hostname + : window.location.hostname) + + '/yunohost/portalapi' + ) +} export function useApi( path: string, @@ -27,7 +30,7 @@ export function useApi( } const query = () => { - return $fetch(apiEndpoint + path, { + return $fetch(useApiEndpoint() + path, { method, credentials: 'include', body,