From c3f497b4d20b897b9817e5c3043860998f470745 Mon Sep 17 00:00:00 2001 From: fbenoist68 Date: Mon, 18 Dec 2023 22:15:59 +0100 Subject: [PATCH] fix: vite_base_url --- src/composables/useApi.ts | 2 +- src/stores/user.store.ts | 2 +- src/utils/api.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/composables/useApi.ts b/src/composables/useApi.ts index 4ec2f82..af9ab8b 100755 --- a/src/composables/useApi.ts +++ b/src/composables/useApi.ts @@ -2,7 +2,7 @@ import { createFetch } from '@vueuse/core' import { destr } from 'destr' export const useApi = createFetch({ - baseUrl: import.meta.env.VITE_API_BASE_URL || '/api', + baseUrl: import.meta.env.VITE_API_BASE_URL, fetchOptions: { headers: { Accept: 'application/json', diff --git a/src/stores/user.store.ts b/src/stores/user.store.ts index b3caeaa..ce2628a 100644 --- a/src/stores/user.store.ts +++ b/src/stores/user.store.ts @@ -11,7 +11,7 @@ export const userStore = defineStore('user', { actions: { async login(username: string, password: string, ability: any) { try { - const res = await $api('http://localhost:8080/hdpos/api/auth/login', { + const res = await $api(`${import.meta.env.VITE_API_BASE_URL}/auth/login`, { method: 'POST', body: { username, diff --git a/src/utils/api.ts b/src/utils/api.ts index 8ef3ee7..7876104 100755 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,7 +1,7 @@ import { ofetch } from 'ofetch' export const $api = ofetch.create({ - baseURL: import.meta.env.VITE_API_BASE_URL || '/api', + baseURL: import.meta.env.VITE_API_BASE_URL, async onRequest({ options }) { const accessToken = useCookie('accessToken').value if (accessToken) {