From 574386f8a2a202fa7758e94007935246faf9819b Mon Sep 17 00:00:00 2001 From: Kulesh Shanmugasundaram <164083+kulesh@users.noreply.github.com> Date: Sun, 21 Dec 2025 22:20:55 -0500 Subject: [PATCH] fix(desktop): use relative URLs when served via local proxy Previously, accessing localhost:PORT would hardcode http://127.0.0.1:4096 for API calls, ignoring the actual server port. Now uses relative URLs by default, which correctly resolve to the serving origin. --- packages/desktop/src/app.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/desktop/src/app.tsx b/packages/desktop/src/app.tsx index 2ed529bbc051..b59d7a0e03fc 100644 --- a/packages/desktop/src/app.tsx +++ b/packages/desktop/src/app.tsx @@ -28,14 +28,11 @@ declare global { } } -const host = import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "127.0.0.1" -const port = window.__OPENCODE__?.port ?? import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096" - const url = new URLSearchParams(document.location.search).get("url") || - (location.hostname.includes("opencode.ai") || location.hostname.includes("localhost") - ? `http://${host}:${port}` - : "/") + (window.__OPENCODE__?.port && `http://127.0.0.1:${window.__OPENCODE__.port}`) || + (location.hostname === "desktop.opencode.ai" && "http://127.0.0.1:4096") || + "/" export function App() { return (