From 4186b80a82a3c324a336fee0f7bf0ae9ed845d12 Mon Sep 17 00:00:00 2001 From: DhanushSantosh Date: Sun, 18 Jan 2026 01:41:21 +0530 Subject: [PATCH] fix: use relative URLs in web mode to leverage Vite proxy In web mode, the API client was hardcoding localhost:3008, which bypassed the Vite proxy and caused CORS errors. Now it uses relative URLs (just /api) in web mode, allowing the proxy to handle routing and making requests appear same-origin. - Web mode: Use relative URLs for proxy routing (no CORS issues) - Electron mode: Continue using hardcoded localhost:3008 This allows the Vite proxy configuration to actually work in web mode. Fixes: Persistent CORS errors in web mode development Co-Authored-By: Claude Haiku 4.5 --- apps/ui/src/lib/http-api-client.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/ui/src/lib/http-api-client.ts b/apps/ui/src/lib/http-api-client.ts index cd0e6739..f069af1c 100644 --- a/apps/ui/src/lib/http-api-client.ts +++ b/apps/ui/src/lib/http-api-client.ts @@ -156,6 +156,12 @@ const getServerUrl = (): string => { if (typeof window !== 'undefined') { const envUrl = import.meta.env.VITE_SERVER_URL; if (envUrl) return envUrl; + + // In web mode (not Electron), use relative URL to leverage Vite proxy + // This avoids CORS issues since requests appear same-origin + if (!window.electron) { + return ''; + } } // Use VITE_HOSTNAME if set, otherwise default to localhost const hostname = import.meta.env.VITE_HOSTNAME || 'localhost';