Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

Move share-link token to URL fragment so it never reaches logs

anirudhkumar-nanonets33311a2daee0
diff --git a/src/web.ts b/src/web.ts
index 418c816f..773d43e4 100644
--- a/src/web.ts
+++ b/src/web.ts
@@ -268,8 +268,10 @@ server.listen(PORT, HOST, () => {
if (EXPOSED && WEB_TOKEN) {
const lan = lanAddress();
console.log(` access token: ${WEB_TOKEN}`);
- if (lan) console.log(` share with your team: http://${lan}:${PORT}/?token=${WEB_TOKEN}`);
- else console.log(` share: http://<this-machine>:${PORT}/?token=${WEB_TOKEN}`);
+ // Token travels in the URL *fragment*: browsers never send fragments over
+ // the network, so it can't leak into proxy or access logs.
+ if (lan) console.log(` share with your team: http://${lan}:${PORT}/#token=${WEB_TOKEN}`);
+ else console.log(` share: http://<this-machine>:${PORT}/#token=${WEB_TOKEN}`);
}
console.log(` graph db: ${p.db}`);
console.log(` extraction: ${p.extraction} (${p.model})`);
diff --git a/src/web/ui.html b/src/web/ui.html
index 10ecd3f6..c1583807 100644
--- a/src/web/ui.html
+++ b/src/web/ui.html
@@ -345,15 +345,15 @@
const $ = (id) => document.getElementById(id);
/* ---------- access token (shared/team deployments) ---------- */
-// A share link carries ?token=…; stash it and strip it from the address bar.
+// A share link carries #token=… in the URL fragment — fragments are never
+// sent to the server, so the token stays out of proxy/access logs. Stash it
+// and strip it from the address bar.
(function pickUpToken() {
- const params = new URLSearchParams(location.search);
- const t = params.get("token");
+ const frag = new URLSearchParams(location.hash.replace(/^#/, ""));
+ const t = frag.get("token");
if (t) {
localStorage.setItem("cg-token", t.trim());
- params.delete("token");
- const qs = params.toString();
- history.replaceState(null, "", location.pathname + (qs ? "?" + qs : ""));
+ history.replaceState(null, "", location.pathname + location.search);
}
})();