openclaw-navigator 5.3.0 → 5.3.2

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.
Files changed (2) hide show
  1. package/cli.mjs +32 -6
  2. 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.2.0
4
+ * openclaw-navigator v5.3.2
5
5
  *
6
6
  * One-command bridge + tunnel for the Navigator browser.
7
7
  * Starts a local bridge, creates a Cloudflare tunnel automatically,
@@ -966,11 +966,13 @@ function handleRequest(req, res) {
966
966
  return;
967
967
  }
968
968
 
969
- // ── Fallback: proxy unmatched paths → OC Web UI (for static assets) ──
970
- // The web UI at localhost:4000 may serve assets at /_next/*, /static/*, etc.
971
- // These don't start with /ui/ but still need to reach the web UI server.
969
+ // ── Fallback: proxy unmatched paths → OC Web UI ──────────────────────
970
+ // Catches /login, /_next/*, /static/*, /favicon.ico, etc.
971
+ // MUST apply the same cookie/redirect/forwarded-header treatment as /ui/*
972
+ // or login won't work (session cookies get lost through the tunnel).
972
973
  {
973
974
  const targetURL = `${path}${url.search}`;
975
+ const incomingHost = req.headers.host || "localhost";
974
976
 
975
977
  const proxyOpts = {
976
978
  hostname: "127.0.0.1",
@@ -980,14 +982,38 @@ function handleRequest(req, res) {
980
982
  headers: {
981
983
  ...req.headers,
982
984
  host: `127.0.0.1:${ocUIPort}`,
985
+ "x-forwarded-host": incomingHost,
986
+ "x-forwarded-proto": activeTunnelURL ? "https" : "http",
987
+ "x-forwarded-for": req.socket.remoteAddress || "127.0.0.1",
983
988
  },
984
989
  };
985
990
 
986
991
  const proxyReq = httpRequest(proxyOpts, (proxyRes) => {
987
992
  const headers = { ...proxyRes.headers };
993
+
994
+ // CORS
988
995
  headers["access-control-allow-origin"] = "*";
989
996
  headers["access-control-allow-methods"] = "GET, POST, PUT, DELETE, OPTIONS";
990
- headers["access-control-allow-headers"] = "Content-Type, Authorization";
997
+ headers["access-control-allow-headers"] = "Content-Type, Authorization, Cookie";
998
+ headers["access-control-allow-credentials"] = "true";
999
+
1000
+ // Fix redirects — strip localhost prefix so browser stays on tunnel URL
1001
+ if (headers.location) {
1002
+ headers.location = headers.location
1003
+ .replace(`http://127.0.0.1:${ocUIPort}`, "")
1004
+ .replace(`http://localhost:${ocUIPort}`, "");
1005
+ }
1006
+
1007
+ // Fix cookies — remove domain restriction + secure flag for tunnel access
1008
+ if (headers["set-cookie"]) {
1009
+ const cookies = Array.isArray(headers["set-cookie"])
1010
+ ? headers["set-cookie"]
1011
+ : [headers["set-cookie"]];
1012
+ headers["set-cookie"] = cookies.map((c) =>
1013
+ c.replace(/;\s*domain=[^;]*/gi, "").replace(/;\s*secure/gi, ""),
1014
+ );
1015
+ }
1016
+
991
1017
  res.writeHead(proxyRes.statusCode ?? 502, headers);
992
1018
  proxyRes.pipe(res, { end: true });
993
1019
  });
@@ -1248,7 +1274,7 @@ module.exports = {
1248
1274
  });
1249
1275
 
1250
1276
  gwSocket.on("error", (err) => {
1251
- console.log(` ${DIM}WS proxy: gateway unreachable — ${err.message}${RESET}`);
1277
+ warn(`WS proxy: gateway on port ${ocGatewayPort} unreachable — ${err.message}`);
1252
1278
  socket.destroy();
1253
1279
  });
1254
1280
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-navigator",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "One-command bridge + tunnel for the Navigator browser — works on any machine, any OS",
5
5
  "keywords": [
6
6
  "browser",