Browse Source

fix: use current page port instead of hardcoded 4096 (#5949)

Co-authored-by: Claude <[email protected]>
lif 2 months ago
parent
commit
d04a72a4ad
1 changed files with 5 additions and 3 deletions
  1. 5 3
      packages/desktop/src/app.tsx

+ 5 - 3
packages/desktop/src/app.tsx

@@ -29,13 +29,15 @@ declare global {
 }
 }
 
 
 const host = import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "127.0.0.1"
 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 port = window.__OPENCODE__?.port ?? import.meta.env.VITE_OPENCODE_SERVER_PORT ?? location.port ?? "4096"
 
 
 const url =
 const url =
   new URLSearchParams(document.location.search).get("url") ||
   new URLSearchParams(document.location.search).get("url") ||
-  (location.hostname.includes("opencode.ai") || location.hostname.includes("localhost")
+  (location.hostname.includes("opencode.ai")
     ? `http://${host}:${port}`
     ? `http://${host}:${port}`
-    : "/")
+    : location.hostname.includes("localhost") || location.hostname === "127.0.0.1"
+      ? `${location.protocol}//${location.host}`
+      : "/")
 
 
 export function App() {
 export function App() {
   return (
   return (