refactor(auth): send login token through apiFetch
Build, Test & Push Frontend / quality-check (push) Successful in 13s
Build, Test & Push Frontend / docker (push) Successful in 23s

All authenticated calls now use apiFetch, and only utils/auth.js
touches the stored token. The cookie login can then change these two
files instead of every page.
This commit is contained in:
lobo committed 2026-09-25 11:29:14 +02:00
1 parent 085fcf15a4
commit 5ff8d48c53
18 files changed
+127 -70

No files matched your search

+5 -5
View File
@@ -1,4 +1,6 @@
import {useEffect, useRef, useState} from 'react';
import {apiFetch} from '../utils/api.js';
import {getToken} from '../utils/auth.js';
const POLL_INTERVAL_MS = 3000;
const MAX_POLL_DURATION_MS = 120_000;
@@ -32,13 +34,11 @@ export default function useLibrarySync({enabled, expectInitialSync = false, onCo
const startedAt = Date.now();
const fetchOnce = async () => {
const token = localStorage.getItem('tbp_jwt');
if (!token) return;
if (!getToken()) return;
try {
const response = await fetch(
`${import.meta.env.VITE_CORE_API_URL}/api/library/sync-status`,
{headers: {'Authorization': `Bearer ${token}`}}
const response = await apiFetch(
`${import.meta.env.VITE_CORE_API_URL}/api/library/sync-status`
);
if (cancelled) return;