feat: overhaul server automation, files editor, and CS2 setup workflows

This commit is contained in:
2026-02-26 21:01:00 +00:00
parent 44c439e2f9
commit 2a3ad5e78f
40 changed files with 4675 additions and 468 deletions
+16 -3
View File
@@ -1,4 +1,9 @@
const API_BASE = '/api';
const RAW_API_BASE = (
(import.meta.env.VITE_API_URL as string | undefined) ??
(import.meta.env.VITE_API_BASE_URL as string | undefined) ??
'/api'
).trim();
const API_BASE = (RAW_API_BASE || '/api').replace(/\/+$/, '');
interface RequestOptions extends RequestInit {
params?: Record<string, string>;
@@ -36,7 +41,11 @@ async function request<T>(path: string, options: RequestOptions = {}): Promise<T
headers['Content-Type'] = 'application/json';
}
const res = await fetch(url, { ...fetchOptions, headers });
const res = await fetch(url, {
...fetchOptions,
credentials: fetchOptions.credentials ?? 'include',
headers,
});
const shouldHandle401WithRefresh =
res.status === 401 &&
@@ -49,7 +58,11 @@ async function request<T>(path: string, options: RequestOptions = {}): Promise<T
const refreshed = await refreshToken();
if (refreshed) {
headers['Authorization'] = `Bearer ${localStorage.getItem('access_token')}`;
const retry = await fetch(url, { ...fetchOptions, headers });
const retry = await fetch(url, {
...fetchOptions,
credentials: fetchOptions.credentials ?? 'include',
headers,
});
if (!retry.ok) throw new ApiError(retry.status, await retry.json().catch(() => null));
if (retry.status === 204) return undefined as T;
return retry.json();