fix: vite_base_url
parent
f6195e51a0
commit
c3f497b4d2
|
|
@ -2,7 +2,7 @@ import { createFetch } from '@vueuse/core'
|
||||||
import { destr } from 'destr'
|
import { destr } from 'destr'
|
||||||
|
|
||||||
export const useApi = createFetch({
|
export const useApi = createFetch({
|
||||||
baseUrl: import.meta.env.VITE_API_BASE_URL || '/api',
|
baseUrl: import.meta.env.VITE_API_BASE_URL,
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export const userStore = defineStore('user', {
|
||||||
actions: {
|
actions: {
|
||||||
async login(username: string, password: string, ability: any) {
|
async login(username: string, password: string, ability: any) {
|
||||||
try {
|
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',
|
method: 'POST',
|
||||||
body: {
|
body: {
|
||||||
username,
|
username,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { ofetch } from 'ofetch'
|
import { ofetch } from 'ofetch'
|
||||||
|
|
||||||
export const $api = ofetch.create({
|
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 }) {
|
async onRequest({ options }) {
|
||||||
const accessToken = useCookie('accessToken').value
|
const accessToken = useCookie('accessToken').value
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue