@devries-cameron20 / t3code-1 / commits / 24fbb5d4c8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(usage): a CLIProxy hub saved as its management.html panel URL shows accounts again (#25579)

Co-authored-by: maria-rcks <maria@kuuro.net>

Jolymmiles committed Nov 6, 2026 at 08:30 UTC 24fbb5d4c83de5a782b1393372a82fbf565f3377
2 files changed +32 -7
apps/server/src/usage/cliproxyApi.test.ts
+26 -2
@@ -264,11 +264,21 @@ describe("CLIProxyAPI built-in management API", () => {
264 }),
265 );
266
267 - it.effect("keeps the path of a hub served under a prefix", () =>
267 + it.effect.each([
268 + "https://tools.test/cliproxy",
269 + "https://tools.test/cliproxy/",
270 + "https://tools.test/cliproxy/management.html",
271 + "https://tools.test/cliproxy/management.html/",
272 + "https://tools.test/cliproxy/MANAGEMENT.HTML",
273 + "https://tools.test/cliproxy/management.html?tab=accounts",
274 + "https://tools.test/cliproxy/management.html#accounts",
275 + "https://tools.test/cliproxy/management.html/?tab=accounts",
276 + "https://tools.test/cliproxy/management.html/#accounts",
277 + ])("keeps the path of a hub served under a prefix: %s", (url) =>
278 Effect.gen(function* () {
279 const test = fixture();
280 const api = yield* test.api;
271 - yield* api.readAccounts({ ...config, url: "https://tools.test/cliproxy" });
281 + yield* api.readAccounts({ ...config, url });
282 expect(test.requests.length).toBeGreaterThan(0);
283 expect(
284 test.requests.every((request) => request.path.startsWith("/cliproxy/v0/management/")),
@@ -276,6 +286,20 @@ describe("CLIProxyAPI built-in management API", () => {
286 }),
287 );
288
289 + it.effect("preserves a hub path that only ends with the panel filename", () =>
290 + Effect.gen(function* () {
291 + const test = fixture();
292 + const api = yield* test.api;
293 + yield* api.readAccounts({ ...config, url: "https://tools.test/team-management.html" });
294 + expect(test.requests.length).toBeGreaterThan(0);
295 + expect(
296 + test.requests.every((request) =>
297 + request.path.startsWith("/team-management.html/v0/management/"),
298 + ),
299 + ).toBe(true);
300 + }),
301 + );
302 +
303 it.effect("keeps usage when the credits endpoint fails", () =>
304 Effect.gen(function* () {
305 const test = fixture({
apps/server/src/usage/cliproxyApi.ts
+6 -5
@@ -184,11 +184,12 @@ export const makeCliproxyApi = Effect.gen(function* () {
184 body?: unknown,
185 ) {
186 const url = yield* Effect.try({
187 - try: () =>
188 - new URL(
189 - `v0/management/${path}`,
190 - hub.url.endsWith("/") ? hub.url : `${hub.url}/`,
191 - ).toString(),
187 + try: () => {
188 + const base = new URL(hub.url);
189 + // Users often paste the hub's web panel URL, which ends in management.html.
190 + base.pathname = base.pathname.replace(/(\/management\.html)?\/?$/i, "/");
191 + return new URL(`v0/management/${path}`, base).toString();
192 + },
193 catch: () => new UsageLimitSourceError({ detail: "The hub URL is not valid." }),
194 });
195 const request = (