fix: use SERVER_IP from network config for backend API calls from VPN

When accessing from VPN/Tailscale (e.g., 100.78.182.28), frontend was trying
to reach backend on that same IP, but backend listens on SERVER_IP instead.
Now uses SERVER_IP from network.json config, ensuring remote clients connect
to the correct server address regardless of their access network.
This commit is contained in:
2026-04-21 15:23:12 +03:00
parent 3c9e5a8149
commit 2daeb1e2ae

View File

@@ -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:') {