@devries-cameron20 / t3code Mirror · read-only / commits / 1dd8c676e4
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 13:15 UTC

fix(desktop): keep development protocol requests on the configured server (#22010)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Victor Vogel committed Oct 29, 2026 at 12:46 UTC 1dd8c676e43f1fd6dee98fa81bdec4a5c3750bab
2 files changed +37 -1
apps/desktop/src/electron/ElectronProtocol.test.ts
+33
@@ -130,6 +130,39 @@ describe("ElectronProtocol", () => {
130 }).pipe(Effect.provide(layerProtocol)),
131 );
132
133 + it.effect("keeps proxied paths on the configured server", () =>
134 + Effect.gen(function* () {
135 + let handler: ((request: Request) => Promise<Response>) | undefined;
136 + handleMock.mockImplementation((_scheme, nextHandler) => {
137 + handler = nextHandler;
138 + });
139 + netFetchMock.mockImplementation(async () => new Response("ok"));
140 +
141 + yield* Effect.scoped(
142 + Effect.gen(function* () {
143 + const protocol = yield* ElectronProtocol.ElectronProtocol;
144 + yield* protocol.registerDesktopProtocol({
145 + scheme: "t3code-dev",
146 + targetOrigin: new URL("http://127.0.0.1:5733/"),
147 + clerkFrontendApiHostname: undefined,
148 + });
149 + yield* Effect.promise(() =>
150 + handler!(new Request("t3code-dev://app//example.com/src/main.tsx?t=1")),
151 + );
152 + yield* Effect.promise(() => handler!(new Request("t3code-dev://app/\\example.com/")));
153 + }),
154 + );
155 +
156 + assert.deepEqual(
157 + netFetchMock.mock.calls.map((call) => call[0]),
158 + [
159 + "http://127.0.0.1:5733//example.com/src/main.tsx?t=1",
160 + "http://127.0.0.1:5733//example.com/",
161 + ],
162 + );
163 + }).pipe(Effect.provide(layerProtocol)),
164 + );
165 +
166 it.effect("rejects custom protocol requests for another host", () =>
167 Effect.gen(function* () {
168 let handler: ((request: Request) => Promise<Response>) | undefined;
apps/desktop/src/electron/ElectronProtocol.ts
+4 -1
@@ -167,7 +167,10 @@ const proxyRequest = Effect.fn("desktop.protocol.proxyRequest")(function* (
167 return new Response(null, { status: 404 });
168 }
169
170 - const targetUrl = new URL(`${requestUrl.pathname}${requestUrl.search}`, targetOrigin);
170 + // Assign the path so leading slashes cannot replace the configured host.
171 + const targetUrl = new URL(targetOrigin);
172 + targetUrl.pathname = requestUrl.pathname;
173 + targetUrl.search = requestUrl.search;
174 const headers = new Headers(request.headers);
175 const headersToRemove: string[] = [];
176 for (const name of headers.keys()) {