claude-code-rehab 1.0.0 → 1.0.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.
- package/index.mjs +34 -12
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -93,7 +93,6 @@ const server = createServer(async (req, res) => {
|
|
|
93
93
|
res.setHeader("Access-Control-Allow-Methods", "GET");
|
|
94
94
|
|
|
95
95
|
if (req.url === "/api/sessions") {
|
|
96
|
-
// Cache for 15 seconds
|
|
97
96
|
if (!cached || Date.now() - lastScan > 15000) {
|
|
98
97
|
cached = await scan();
|
|
99
98
|
lastScan = Date.now();
|
|
@@ -101,17 +100,40 @@ const server = createServer(async (req, res) => {
|
|
|
101
100
|
res.setHeader("Content-Type", "application/json");
|
|
102
101
|
res.end(JSON.stringify({ sessions: cached, meta: { sessionCount: cached.length, lastRefresh: lastScan, ready: true } }));
|
|
103
102
|
} else {
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
// Proxy to Vercel frontend — avoids HTTPS mixed-content issues
|
|
104
|
+
const target = `https://claude-code-rehab.vercel.app${req.url === "/" ? "/" : req.url}`;
|
|
105
|
+
try {
|
|
106
|
+
const resp = await fetch(target);
|
|
107
|
+
const ct = resp.headers.get("content-type") || "text/html";
|
|
108
|
+
res.writeHead(resp.status, { "Content-Type": ct, "Cache-Control": "public, max-age=3600" });
|
|
109
|
+
const buf = Buffer.from(await resp.arrayBuffer());
|
|
110
|
+
res.end(buf);
|
|
111
|
+
} catch {
|
|
112
|
+
res.writeHead(502);
|
|
113
|
+
res.end("Failed to load frontend. Visit https://claude-code-rehab.vercel.app directly.");
|
|
114
|
+
}
|
|
106
115
|
}
|
|
107
116
|
});
|
|
108
117
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
function tryListen(port) {
|
|
119
|
+
server.listen(port, "0.0.0.0", () => {
|
|
120
|
+
const ips = getLocalIPs();
|
|
121
|
+
console.log("\n Claude Code Rehab — Ready!\n");
|
|
122
|
+
console.log(` Open in browser:`);
|
|
123
|
+
console.log(` http://localhost:${port}`);
|
|
124
|
+
ips.forEach(ip => console.log(` http://${ip}:${port}`));
|
|
125
|
+
console.log(`\n Phone? Same WiFi, open the Network URL above.`);
|
|
126
|
+
console.log("\n Ctrl+C to stop\n");
|
|
127
|
+
});
|
|
128
|
+
server.on("error", (e) => {
|
|
129
|
+
if (e.code === "EADDRINUSE" && port < PORT + 10) {
|
|
130
|
+
console.log(` Port ${port} in use, trying ${port + 1}...`);
|
|
131
|
+
server.close();
|
|
132
|
+
tryListen(port + 1);
|
|
133
|
+
} else {
|
|
134
|
+
console.error(` Error: ${e.message}`);
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
tryListen(PORT);
|