fixed network config and wrong paths in frontend

This commit is contained in:
2025-12-29 22:12:39 +01:00
parent 610fd74e89
commit fb514f1efe
14 changed files with 599 additions and 36 deletions

View File

@@ -1,3 +1,4 @@
import { fetch } from '@tauri-apps/plugin-http';
import { initAuth, logout } from '../store.ts'
import { API } from '../main.ts'
import router from '../router'
@@ -9,6 +10,8 @@ export async function apiFetch<T>(
const auth = await initAuth()
const res = await fetch(`${API}${path}`, {
method: options.method || 'GET',
body: options.body,
...options,
headers: {
'Content-Type': 'application/json',
@@ -28,5 +31,5 @@ export async function apiFetch<T>(
throw new Error(text || res.statusText)
}
return res.json()
return res.json() as Promise<T>
}

View File

@@ -1,5 +1,5 @@
import { apiFetch } from './client'
import type { Friend, FriendRequest } from '../api'
import type { Friend, FriendRequest } from '../types'
export function fetchFriends() {
return apiFetch<Friend[]>('/friends')

View File

@@ -1,5 +1,5 @@
import { apiFetch } from './client'
import type { Message } from '../api'
import type { Message } from '../types'
export function fetchMessages(roomUuid: string) {
return apiFetch<Message[]>(`/messages/${roomUuid}`)

View File

@@ -1,5 +1,5 @@
import { apiFetch } from './client'
import type { Room } from '../api'
import type { Room } from '../types'
export function fetchRooms(userUuid: string) {
return apiFetch<Room[]>(`/rooms/${userUuid}`)