openclaw-navigator 5.6.2 → 5.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +19 -4
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -1363,6 +1363,10 @@ function handleRequest(req, res) {
|
|
|
1363
1363
|
{
|
|
1364
1364
|
const targetURL = `${path}${url.search}`;
|
|
1365
1365
|
const incomingHost = req.headers.host || "localhost";
|
|
1366
|
+
// Log API calls for diagnostics (helps debug web UI chat)
|
|
1367
|
+
if (path.startsWith("/api/")) {
|
|
1368
|
+
console.log(` ${DIM}→ Proxy ${req.method} ${path} → localhost:${ocUIPort}${RESET}`);
|
|
1369
|
+
}
|
|
1366
1370
|
|
|
1367
1371
|
// Encourage JSON responses from the web UI's API routes
|
|
1368
1372
|
const proxyHeaders = {
|
|
@@ -1373,8 +1377,10 @@ function handleRequest(req, res) {
|
|
|
1373
1377
|
"x-forwarded-for": req.socket.remoteAddress || "127.0.0.1",
|
|
1374
1378
|
};
|
|
1375
1379
|
|
|
1376
|
-
// For /api/* requests, prefer JSON over SSE
|
|
1377
|
-
|
|
1380
|
+
// For /api/* requests, prefer JSON over SSE — BUT not for streaming chat endpoints
|
|
1381
|
+
// which need text/event-stream to get SSE responses from the BFF
|
|
1382
|
+
const isStreamingReq = path.startsWith("/api/chat") || path.startsWith("/api/stream");
|
|
1383
|
+
if (path.startsWith("/api/") && !isStreamingReq) {
|
|
1378
1384
|
proxyHeaders["accept"] = "application/json, text/plain, */*";
|
|
1379
1385
|
}
|
|
1380
1386
|
|
|
@@ -1389,6 +1395,12 @@ function handleRequest(req, res) {
|
|
|
1389
1395
|
const proxyReq = httpRequest(proxyOpts, (proxyRes) => {
|
|
1390
1396
|
const headers = { ...proxyRes.headers };
|
|
1391
1397
|
|
|
1398
|
+
// Log response info for API calls (helps debug web UI chat)
|
|
1399
|
+
if (path.startsWith("/api/")) {
|
|
1400
|
+
const ct = (proxyRes.headers["content-type"] || "unknown").split(";")[0];
|
|
1401
|
+
console.log(` ${DIM}← ${proxyRes.statusCode} ${ct} for ${path}${RESET}`);
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1392
1404
|
// CORS
|
|
1393
1405
|
headers["access-control-allow-origin"] = "*";
|
|
1394
1406
|
headers["access-control-allow-methods"] = "GET, POST, PUT, DELETE, OPTIONS";
|
|
@@ -1550,8 +1562,11 @@ function handleRequest(req, res) {
|
|
|
1550
1562
|
proxyRes.pipe(res, { end: true });
|
|
1551
1563
|
});
|
|
1552
1564
|
|
|
1553
|
-
proxyReq.on("error", () => {
|
|
1554
|
-
|
|
1565
|
+
proxyReq.on("error", (err) => {
|
|
1566
|
+
if (path.startsWith("/api/")) {
|
|
1567
|
+
console.log(` ${DIM}✗ Proxy error for ${path}: ${err.message}${RESET}`);
|
|
1568
|
+
}
|
|
1569
|
+
sendJSON(res, 502, { ok: false, error: `Web UI (port ${ocUIPort}) not reachable: ${err.message}` });
|
|
1555
1570
|
});
|
|
1556
1571
|
|
|
1557
1572
|
req.pipe(proxyReq, { end: true });
|