fix: fix Docker dev proxy and handle non-JSON error responses in frontend

This commit is contained in:
2026-04-02 14:48:40 +08:00
parent 0905b0302b
commit 5f76abec8b
3 changed files with 9 additions and 2 deletions

View File

@@ -66,7 +66,13 @@ export async function apiFetch<T>(path: string, options: RequestInit = {}): Prom
}
}
const json: ApiResponse<T> = await res.json();
const text = await res.text();
let json: ApiResponse<T>;
try {
json = JSON.parse(text);
} catch {
throw new Error(`Server error (${res.status})`);
}
if (!json.success) {
throw new Error(json.error?.message || 'Request failed');
}