Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(frontend): name endpoint and status in fallback API error

Juan Denisdf63abe74afe
diff --git a/frontend/src/services/api/client.js b/frontend/src/services/api/client.js
index b79064d3..e2a7e03f 100644
--- a/frontend/src/services/api/client.js
+++ b/frontend/src/services/api/client.js
@@ -107,7 +107,14 @@ class ApiClient {
async handleResponse(response) {
const data = await response.json().catch(() => ({}));
if (!response.ok) {
- const err = new Error(data.error || data.msg || 'Request failed');
+ // No server-provided message means the route itself misbehaved
+ // (404 unknown endpoint, 405 SPA catch-all, 502 proxy...) — name
+ // the endpoint and status so the toast is diagnosable.
+ let fallback = `Request failed (${response.status})`;
+ try {
+ fallback += `: ${new URL(response.url).pathname}`;
+ } catch { /* keep the status-only message */ }
+ const err = new Error(data.error || data.msg || fallback);
err.status = response.status;
err.data = data;
throw err;