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

+6 -4
View File
@@ -1,3 +1,5 @@
import {apiFetch} from './api.js';
export const GAME_STATUSES = ['BACKLOG', 'PLAYING', 'FINISHED', 'COMPLETED', 'DROPPED'];
export const GAME_PRIORITIES = ['HIGH', 'MEDIUM', 'LOW'];
@@ -19,9 +21,9 @@ export const toBacklogRequest = ({status, rating, notes, priority}) => ({
* @param entry a backlog entry in request form, see toBacklogRequest
*/
export const saveBacklogEntry = (appid, entry) =>
fetch(`${import.meta.env.VITE_CORE_API_URL}/api/library/games/${appid}/backlog`, {
apiFetch(`${import.meta.env.VITE_CORE_API_URL}/api/library/games/${appid}/backlog`, {
method: 'PUT',
headers: {'Authorization': `Bearer ${localStorage.getItem('tbp_jwt')}`, 'Content-Type': 'application/json'},
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(entry),
});
@@ -29,9 +31,9 @@ export const saveBacklogEntry = (appid, entry) =>
* PUT /api/library/games/{appid}/status. The caller handles the response status.
*/
export const saveGameStatus = (appid, status) =>
fetch(`${import.meta.env.VITE_CORE_API_URL}/api/library/games/${appid}/status`, {
apiFetch(`${import.meta.env.VITE_CORE_API_URL}/api/library/games/${appid}/status`, {
method: 'PUT',
headers: {'Authorization': `Bearer ${localStorage.getItem('tbp_jwt')}`, 'Content-Type': 'application/json'},
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({status}),
});