From e6c46f9f071c05de92e11edc8cd89a323ccb8715 Mon Sep 17 00:00:00 2001 From: AuditAIH <145266260+AuditAIH@users.noreply.github.com> Date: Wed, 29 Jul 2026 17:40:17 +0800 Subject: [PATCH] fix(app): use precise hostname match instead of substring for opencode.ai Replace String.includes() with a regex that only matches opencode.ai and *.opencode.ai. The previous substring match caused false positives on domains like opencode.aid.example.com, forcing the backend URL to localhost:4096 instead of location.origin. Fixes #39479 --- packages/app/src/entry.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/entry.tsx b/packages/app/src/entry.tsx index c41c1bb4b63e..3389caef5257 100644 --- a/packages/app/src/entry.tsx +++ b/packages/app/src/entry.tsx @@ -100,7 +100,7 @@ if (!(root instanceof HTMLElement) && import.meta.env.DEV) { } const getCurrentUrl = () => { - if (location.hostname.includes("opencode.ai")) return "http://localhost:4096" + if (/(^|\.)opencode\.ai$/.test(location.hostname)) 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"}` return location.origin