fix: allow slow API requests through nginx and explain proxy errors

Raise the /api proxy timeout from 60s to 300s, the longest AI timeout the
settings allow. When a proxy answers with an HTML error page, show a short
message instead of the raw HTML.
This commit is contained in:
Tautvydas Derzinskas committed 2026-10-11 21:16:56 +02:00
1 parent 5fcadfb179
commit 4d4d2209e6
2 files changed
+9 -1

No files matched your search

+3 -1
View File
@@ -17,7 +17,9 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 60s;
# Long enough for the slowest request: a slow local AI model may take up to the 300s
# timeout its settings allow.
proxy_read_timeout 300s;
client_max_body_size 512m;
}
+6
View File
@@ -48,5 +48,11 @@ export async function readErrorMessage(res: Response, fallback: string) {
return data.detail.trim();
}
} catch {}
// An HTML page comes from a proxy in front of the backend, not from Thingport.
if (/^<(!doctype|html)/i.test(trimmed)) {
if (res.status === 504)
return "The server took too long to answer, and a proxy in front of Thingport gave up (HTTP 504).";
return `${fallback} (HTTP ${res.status})`;
}
return trimmed;
}