claude-code-rehab 1.0.1 → 1.1.0
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 +19 -7
- 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,20 +100,33 @@ 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
118
|
function tryListen(port) {
|
|
110
119
|
server.listen(port, "0.0.0.0", () => {
|
|
111
120
|
const ips = getLocalIPs();
|
|
112
|
-
|
|
113
|
-
console.log(
|
|
121
|
+
const url = `http://localhost:${port}`;
|
|
122
|
+
console.log("\n Claude Code Rehab — Ready!\n");
|
|
123
|
+
console.log(` Local: ${url}`);
|
|
114
124
|
ips.forEach(ip => console.log(` Network: http://${ip}:${port}`));
|
|
115
|
-
console.log(`\n
|
|
116
|
-
ips.forEach(ip => console.log(` ${ip}:${port}`));
|
|
125
|
+
console.log(`\n Phone? Same WiFi, open the Network URL above.`);
|
|
117
126
|
console.log("\n Ctrl+C to stop\n");
|
|
127
|
+
// Auto-open browser
|
|
128
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
129
|
+
import("child_process").then(cp => cp.exec(`${cmd} ${url}`)).catch(() => {});
|
|
118
130
|
});
|
|
119
131
|
server.on("error", (e) => {
|
|
120
132
|
if (e.code === "EADDRINUSE" && port < PORT + 10) {
|