Merge fix/wizard-init-flow and fix/three-bugs-2026-03-22 into unified branch

This commit is contained in:
zhi
2026-03-22 10:17:52 +00:00
3 changed files with 34 additions and 14 deletions

View File

@@ -24,6 +24,10 @@ 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 getApiBase = () => {
return localStorage.getItem('HF_BACKEND_BASE_URL') || import.meta.env.VITE_API_BASE || 'http://127.0.0.1:8000'
}
type AppState = 'checking' | 'setup' | 'ready'
export default function App() {
@@ -35,6 +39,22 @@ export default function App() {
}, [])
const checkInitialized = async () => {
// First try the backend /config/status endpoint (reads from config volume directly)
try {
const res = await axios.get(`${getApiBase()}/config/status`, { 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 {
// 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,
@@ -49,7 +69,7 @@ export default function App() {
setAppState('setup')
}
} catch {
// Wizard unreachable or config doesn't exist → setup needed
// Neither backend nor wizard reachable → setup needed
setAppState('setup')
}
}