From 0dbfefa08088270a000496cfe94e11b5bf3ce821 Mon Sep 17 00:00:00 2001
From: Adam <2363879+adamdotdevin@users.noreply.github.com>
Date: Tue, 24 Mar 2026 18:49:02 -0500
Subject: Reapply "fix(app): startup efficiency (#18854)"

This reverts commit a379eb38673aad097e1f178307865ec40a5ac3ea.
---
 packages/app/src/entry.tsx | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'packages/app/src/entry.tsx')

diff --git a/packages/app/src/entry.tsx b/packages/app/src/entry.tsx
index b5cbed6e7..da22c5552 100644
--- a/packages/app/src/entry.tsx
+++ b/packages/app/src/entry.tsx
@@ -97,10 +97,15 @@ if (!(root instanceof HTMLElement) && import.meta.env.DEV) {
   throw new Error(getRootNotFoundError())
 }
 
+const localUrl = () =>
+  `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}`
+
+const isLocalHost = () => ["localhost", "127.0.0.1", "0.0.0.0"].includes(location.hostname)
+
 const getCurrentUrl = () => {
-  if (location.hostname.includes("opencode.ai")) return "http://localhost:4096"
-  if (import.meta.env.DEV)
-    return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}`
+  if (location.hostname.includes("opencode.ai")) return localUrl()
+  if (import.meta.env.DEV) return localUrl()
+  if (isLocalHost()) return localUrl()
   return location.origin
 }
 
-- 
cgit v1.2.3

