openclaw-navigator 5.5.0 → 5.5.1
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 +15 -46
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* openclaw-navigator v5.5.
|
|
4
|
+
* openclaw-navigator v5.5.1
|
|
5
5
|
*
|
|
6
6
|
* One-command bridge + tunnel for the Navigator browser.
|
|
7
7
|
* Starts a local bridge, creates a Cloudflare tunnel automatically,
|
|
@@ -1278,51 +1278,20 @@ function handleRequest(req, res) {
|
|
|
1278
1278
|
return;
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
|
-
// ──
|
|
1282
|
-
//
|
|
1283
|
-
//
|
|
1284
|
-
//
|
|
1285
|
-
//
|
|
1286
|
-
//
|
|
1287
|
-
//
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
method: req.method,
|
|
1296
|
-
headers: {
|
|
1297
|
-
...req.headers,
|
|
1298
|
-
host: `127.0.0.1:${ocGatewayPort}`,
|
|
1299
|
-
},
|
|
1300
|
-
};
|
|
1301
|
-
|
|
1302
|
-
const proxyReq = httpRequest(proxyOpts, (proxyRes) => {
|
|
1303
|
-
const headers = { ...proxyRes.headers };
|
|
1304
|
-
headers["access-control-allow-origin"] = "*";
|
|
1305
|
-
headers["access-control-allow-methods"] = "GET, POST, PUT, DELETE, OPTIONS";
|
|
1306
|
-
headers["access-control-allow-headers"] = "Content-Type, Authorization";
|
|
1307
|
-
res.writeHead(proxyRes.statusCode ?? 502, headers);
|
|
1308
|
-
proxyRes.pipe(res, { end: true });
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
proxyReq.on("error", (err) => {
|
|
1312
|
-
sendJSON(res, 502, {
|
|
1313
|
-
ok: false,
|
|
1314
|
-
error: `OC Gateway not reachable on port ${ocGatewayPort}`,
|
|
1315
|
-
detail: err.message,
|
|
1316
|
-
hint:
|
|
1317
|
-
"Make sure the OC gateway is running on port " +
|
|
1318
|
-
ocGatewayPort +
|
|
1319
|
-
" (openclaw gateway start)",
|
|
1320
|
-
});
|
|
1321
|
-
});
|
|
1322
|
-
|
|
1323
|
-
req.pipe(proxyReq, { end: true });
|
|
1324
|
-
return;
|
|
1325
|
-
}
|
|
1281
|
+
// ── /api/* routing strategy ──────────────────────────────────────────────
|
|
1282
|
+
// NO direct gateway proxy for /api/* here. The web UI (Next.js on port 4000)
|
|
1283
|
+
// has its own /api/* routes that act as a BFF (Backend for Frontend) —
|
|
1284
|
+
// they call the gateway internally (localhost:18789) and return clean JSON.
|
|
1285
|
+
// Routing /api/* directly to the gateway bypasses the BFF and breaks things
|
|
1286
|
+
// (e.g. /api/agents returns raw SSE instead of JSON).
|
|
1287
|
+
//
|
|
1288
|
+
// Specific bridge-handled routes (above this point):
|
|
1289
|
+
// - /api/sessions/respond → local WebSocket broadcast
|
|
1290
|
+
// - /api/sessions/stream → local WebSocket broadcast
|
|
1291
|
+
// - /api/sessions/send → smart SSE bridge to gateway (sidepane chat)
|
|
1292
|
+
//
|
|
1293
|
+
// Everything else (/api/agents, /api/auth/*, /api/chat/*, etc.) falls through
|
|
1294
|
+
// to the fallback proxy below, which sends it to port 4000 (web UI).
|
|
1326
1295
|
|
|
1327
1296
|
// ── Root → redirect to /ui/ (Next.js basePath) or show bridge status ──
|
|
1328
1297
|
if (req.method === "GET" && path === "") {
|