From 62cb1f2d4dcf7fd89b251e815660728aed8f3275 Mon Sep 17 00:00:00 2001 From: TheDancingDeveloper Date: Wed, 29 Jul 2026 10:48:51 +0000 Subject: [PATCH] fix(webui): use same-origin API for production route --- crates/librtbit/webui/src/http-api.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/librtbit/webui/src/http-api.ts b/crates/librtbit/webui/src/http-api.ts index 928faf2..f5c5bb8 100644 --- a/crates/librtbit/webui/src/http-api.ts +++ b/crates/librtbit/webui/src/http-api.ts @@ -52,8 +52,14 @@ const apiUrl = (() => { const url = new URL(window.location.href); - // assume Vite devserver - if (url.port == "3031" || url.port == "1420") { + // Vite's development server runs on 3031 and forwards API requests to a + // separately running backend on 3030. The production web UI is served by + // rtbit itself under /web/ on the API port, so it must use same-origin API + // requests. The desktop dev shell on 1420 also talks to the backend on 3030. + if (url.port == "3031" && (url.pathname === "/" || url.pathname === "")) { + return `${url.protocol}//${url.hostname}:3030`; + } + if (url.port == "1420") { return `${url.protocol}//${url.hostname}:3030`; }