Spaces:
Running
Running
Z User commited on
Commit ·
11dc522
1
Parent(s): 88cdea1
fix: serve WebUI static files directly, proxy /assets/* to client dir
Browse files- /webui serves index.html from webui-client
- /assets/*, /favicon* served from webui-client directly
- /api/* still proxied to BFF on :6060
- Avoid BFF / route issue by serving static files locally
entry.py
CHANGED
|
@@ -390,31 +390,48 @@ class ProxyHandler(BaseHTTPRequestHandler):
|
|
| 390 |
if path == "/api/logs/stream":
|
| 391 |
return self._handle_sse()
|
| 392 |
|
| 393 |
-
# ── WebUI
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
path.
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
path.
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
#
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
|
| 419 |
self.send_error(404)
|
| 420 |
|
|
|
|
| 390 |
if path == "/api/logs/stream":
|
| 391 |
return self._handle_sse()
|
| 392 |
|
| 393 |
+
# ── WebUI SPA: /webui, /webui/* → serve from webui-client static dir ──
|
| 394 |
+
if path.startswith("/webui"):
|
| 395 |
+
# Map /webui → /, /webui/xxx → /xxx for the static dir
|
| 396 |
+
if path in ("/webui", "/webui/"):
|
| 397 |
+
index_path = os.path.join(WEBUI_CLIENT_DIR, "index.html")
|
| 398 |
+
if os.path.isfile(index_path):
|
| 399 |
+
return self._send_html(index_path)
|
| 400 |
+
# Try static file
|
| 401 |
+
static_path = os.path.join(WEBUI_CLIENT_DIR, path[len("/webui"):].lstrip("/"))
|
| 402 |
+
if os.path.isfile(static_path):
|
| 403 |
+
return self._send_file(static_path)
|
| 404 |
+
# SPA fallback
|
| 405 |
+
index_path = os.path.join(WEBUI_CLIENT_DIR, "index.html")
|
| 406 |
+
if os.path.isfile(index_path):
|
| 407 |
+
return self._send_html(index_path)
|
| 408 |
+
# Final fallback: proxy to BFF
|
| 409 |
+
return self._forward_to_webui(path[5:] or "/", "GET")
|
| 410 |
+
|
| 411 |
+
# ── WebUI static assets (referenced by SPA as /assets/*, /favicon*) ──
|
| 412 |
+
# These must be served from webui-client dir because the SPA uses absolute paths
|
| 413 |
+
if path.startswith("/assets/") or path.startswith("/favicon") or path == "/logo.png":
|
| 414 |
+
static_path = os.path.join(WEBUI_CLIENT_DIR, path.lstrip("/"))
|
| 415 |
+
if os.path.isfile(static_path):
|
| 416 |
+
return self._send_file(static_path)
|
| 417 |
+
# If not found locally, try proxying to BFF
|
| 418 |
+
return self._forward_to_webui(self.path, "GET")
|
| 419 |
+
|
| 420 |
+
# ── WebUI API routes: /api/*, /v1/* → proxy to WebUI BFF ──
|
| 421 |
+
if path.startswith("/api/") or path.startswith("/v1/"):
|
| 422 |
+
return self._forward_to_webui(self.path, "GET")
|
| 423 |
+
|
| 424 |
+
# ── /health → proxy to BFF ──
|
| 425 |
+
if path == "/health":
|
| 426 |
+
return self._forward_to_webui("/health", "GET")
|
| 427 |
+
|
| 428 |
+
# ── /upload, /webhook → proxy to BFF ──
|
| 429 |
+
if path in ("/upload", "/webhook"):
|
| 430 |
+
return self._forward_to_webui(self.path, "GET")
|
| 431 |
+
|
| 432 |
+
# ── /socket.io/* → proxy to BFF (WebSocket upgrade handled separately) ──
|
| 433 |
+
if path.startswith("/socket.io/"):
|
| 434 |
+
return self._forward_to_webui(self.path, "GET")
|
| 435 |
|
| 436 |
self.send_error(404)
|
| 437 |
|