.NET: DevUI: Use relative URLs for backend API by default (#2005)

* DevUI: Use relative URLs for backend API by default

* dotnet format

* rebuild application
This commit is contained in:
Reuben Bond
2025-11-07 09:01:04 -08:00
committed by GitHub
Unverified
parent 00b67e191b
commit 3d94ae57ed
6 changed files with 20 additions and 27 deletions
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@ export function SettingsModal({ open, onOpenChange, onBackendUrlChange }: Settin
const [activeTab, setActiveTab] = useState<Tab>("settings");
// Get current backend URL from localStorage or default
const defaultUrl = import.meta.env.VITE_API_BASE_URL || "http://localhost:8080";
const defaultUrl = import.meta.env.VITE_API_BASE_URL !== undefined ? import.meta.env.VITE_API_BASE_URL : "";
const [backendUrl, setBackendUrl] = useState(() => {
return localStorage.getItem("devui_backend_url") || defaultUrl;
});
@@ -61,7 +61,7 @@ interface ConversationApiResponse {
const DEFAULT_API_BASE_URL =
import.meta.env.VITE_API_BASE_URL !== undefined
? import.meta.env.VITE_API_BASE_URL
: "http://localhost:8080";
: ""; // Default to relative URLs (same host as frontend)
// Retry configuration for streaming
const RETRY_INTERVAL_MS = 1000; // Retry every second
@@ -72,12 +72,6 @@ function getBackendUrl(): string {
const stored = localStorage.getItem("devui_backend_url");
if (stored) return stored;
// If VITE_API_BASE_URL is explicitly set to empty string, use relative path
// This allows the frontend to call the same host it's served from
if (import.meta.env.VITE_API_BASE_URL === "") {
return "";
}
return DEFAULT_API_BASE_URL;
}