fix: vite_base_url

refactor/issue-1/first-setup
Frédérik Benoist 2023-12-18 22:15:59 +01:00
parent f6195e51a0
commit c3f497b4d2
3 changed files with 3 additions and 3 deletions

View File

@ -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',

View File

@ -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,

View File

@ -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) {