fix: fix Docker dev proxy and handle non-JSON error responses in frontend
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user