Update secure-gateway-setup.tsx

This commit is contained in:
MacRimi
2026-03-14 20:53:42 +01:00
parent b43d8918bd
commit a3f4277bdc

View File

@@ -22,11 +22,12 @@ import { fetchApi } from "../lib/api-config"
interface NetworkInfo { interface NetworkInfo {
interface: string interface: string
type: string type?: string
address: string address?: string
ip?: string
subnet: string subnet: string
prefixlen: number prefixlen?: number
recommended: boolean recommended?: boolean
} }
interface AppStatus { interface AppStatus {
@@ -145,11 +146,13 @@ export function SecureGatewaySetup() {
const networksRes = await fetchApi("/api/oci/networks") const networksRes = await fetchApi("/api/oci/networks")
if (networksRes.success) { if (networksRes.success) {
setNetworks(networksRes.networks || []) setNetworks(networksRes.networks || [])
// Get host IP for "Host Only" mode - extract just the IP without CIDR // Get host IP for "Host Only" mode
const primaryNetwork = networksRes.networks?.find((n: NetworkInfo) => n.recommended) || networksRes.networks?.[0] const primaryNetwork = networksRes.networks?.find((n: NetworkInfo) => n.recommended) || networksRes.networks?.[0]
if (primaryNetwork?.address) { // Backend returns "ip" field with the host IP address
const hostIpValue = primaryNetwork?.ip || primaryNetwork?.address
if (hostIpValue) {
// Remove CIDR notation if present (e.g., "192.168.0.55/24" -> "192.168.0.55") // Remove CIDR notation if present (e.g., "192.168.0.55/24" -> "192.168.0.55")
const ip = primaryNetwork.address.split("/")[0] const ip = hostIpValue.split("/")[0]
setHostIp(ip) setHostIp(ip)
console.log("[v0] Host IP for Host Only mode:", ip) console.log("[v0] Host IP for Host Only mode:", ip)
} }