diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index f8a661f0..b9541f46 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -29,10 +29,12 @@ export const getNetworkConfig = async () => { export const getBackendUrl = async () => { const config = await getNetworkConfig(); - + if (typeof window === 'undefined') return `http://localhost:${config.BACKEND_PORT}`; - const host = window.location.hostname; + // Use SERVER_IP from config (set during startup) instead of window.location.hostname + // This ensures VPN/remote clients connect to the correct server IP, not their access IP + const host = config.SERVER_IP || window.location.hostname; // If we are on HTTPS (Proxy/Mobile mode), we use the SSL port for the backend if (window.location.protocol === 'https:') {