summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/entry.tsx
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-03-24 18:49:02 -0500
committerAdam <[email protected]>2026-03-25 05:59:05 -0500
commit0dbfefa08088270a000496cfe94e11b5bf3ce821 (patch)
tree022df9271b5825e7c8e1192f240d31de79904075 /packages/app/src/entry.tsx
parentd1c49ba210315900b7d21a7d4926b739d8021c6e (diff)
downloadopencode-0dbfefa08088270a000496cfe94e11b5bf3ce821.tar.gz
opencode-0dbfefa08088270a000496cfe94e11b5bf3ce821.zip
Reapply "fix(app): startup efficiency (#18854)"
This reverts commit a379eb38673aad097e1f178307865ec40a5ac3ea.
Diffstat (limited to 'packages/app/src/entry.tsx')
-rw-r--r--packages/app/src/entry.tsx11
1 files changed, 8 insertions, 3 deletions
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
}