quick fix

This commit is contained in:
h z
2026-04-15 07:14:36 +01:00
parent 0b55bc873e
commit 6432255203
4 changed files with 76 additions and 89 deletions

View File

@@ -22,8 +22,10 @@ import SupportDetailPage from '@/pages/SupportDetailPage'
import MeetingDetailPage from '@/pages/MeetingDetailPage'
import axios from 'axios'
const WIZARD_PORT = Number(import.meta.env.VITE_WIZARD_PORT) || 18080
const WIZARD_BASE = `http://127.0.0.1:${WIZARD_PORT}`
const getStoredWizardPort = (): number | null => {
const stored = Number(localStorage.getItem('HF_WIZARD_PORT'))
return stored && stored > 0 ? stored : null
}
const getApiBase = () => {
return localStorage.getItem('HF_BACKEND_BASE_URL') ?? undefined
@@ -55,24 +57,26 @@ export default function App() {
// Backend unreachable — fall through to wizard check
}
// Fallback: try the wizard directly (needed during initial setup before backend starts)
try {
const res = await axios.get(`${WIZARD_BASE}/api/v1/config/harborforge.json`, {
timeout: 5000,
})
const cfg = res.data || {}
if (cfg.backend_url) {
localStorage.setItem('HF_BACKEND_BASE_URL', cfg.backend_url)
// Fallback: if a wizard port was previously saved during setup, try it directly
const storedPort = getStoredWizardPort()
if (storedPort) {
try {
const res = await axios.get(`http://127.0.0.1:${storedPort}/api/v1/config/harborforge.json`, {
timeout: 5000,
})
const cfg = res.data || {}
if (cfg.backend_url) {
localStorage.setItem('HF_BACKEND_BASE_URL', cfg.backend_url)
}
if (cfg.initialized === true) {
setAppState('ready')
return
}
} catch {
// ignore — fall through to setup
}
if (cfg.initialized === true) {
setAppState('ready')
} else {
setAppState('setup')
}
} catch {
// Neither backend nor wizard reachable → setup needed
setAppState('setup')
}
setAppState('setup')
}
if (appState === 'checking') {
@@ -80,7 +84,7 @@ export default function App() {
}
if (appState === 'setup') {
return <SetupWizardPage wizardBase={WIZARD_BASE} onComplete={checkInitialized} />
return <SetupWizardPage initialWizardPort={getStoredWizardPort()} onComplete={checkInitialized} />
}
if (loading) return <div className="loading">Loading...</div>