refactor/issue-1/first-setup #9
@ -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',
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user