@devries-cameron20 / t3code-1 / commits / def17b215f
Fork 0

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

fix(usage): a CLIProxyAPI hub served under a path keeps its path (#19336)

Quy Ngoc Nguyen committed Oct 19, 2026 at 02:35 UTC def17b215f5a4e2293e59ecc863127a4b22e1dbd
2 files changed +18 -2
apps/server/src/usage/cliproxyApi.test.ts
+13 -1
@@ -73,7 +73,7 @@ function fixture(
73 request,
74 Response.json({}, { status: options.cooldownStatus ?? 200 }),
75 );
76 - expect(path).toBe("/v0/management/api-call");
76 + expect(path).toMatch(/\/v0\/management\/api-call$/);
77 expect(body?.header?.Authorization).toBe("Bearer $TOKEN$");
78 const upstream = options.upstream?.(body!) ?? {
79 status: 200,
@@ -145,6 +145,18 @@ describe("CLIProxyAPI built-in management API", () => {
145 }),
146 );
147
148 + it.effect("keeps the path of a hub served under a prefix", () =>
149 + Effect.gen(function* () {
150 + const test = fixture();
151 + const api = yield* test.api;
152 + yield* api.readAccounts({ ...config, url: "https://tools.test/cliproxy" });
153 + expect(test.requests.length).toBeGreaterThan(0);
154 + expect(
155 + test.requests.every((request) => request.path.startsWith("/cliproxy/v0/management/")),
156 + ).toBe(true);
157 + }),
158 + );
159 +
160 it.effect("keeps usage when the credits endpoint fails", () =>
161 Effect.gen(function* () {
162 const test = fixture({
apps/server/src/usage/cliproxyApi.ts
+5 -1
@@ -130,7 +130,11 @@ export const makeCliproxyApi = Effect.gen(function* () {
130 body?: unknown,
131 ) {
132 const url = yield* Effect.try({
133 - try: () => new URL(`/v0/management/${path}`, config.url).toString(),
133 + try: () =>
134 + new URL(
135 + `v0/management/${path}`,
136 + config.url.endsWith("/") ? config.url : `${config.url}/`,
137 + ).toString(),
138 catch: () => new UsageLimitSourceError({ detail: "The hub URL is not valid." }),
139 });
140 const request = (