fix: check wizard config for initialized flag instead of backend health

- App checks wizard API for harborforge.json config with initialized=true
- If not initialized, show embedded setup wizard (talks to wizard API via CORS)
- Setup saves config with initialized:true to wizard config volume
- After restart, backend reads config and starts, frontend sees initialized=true
- Remove VITE_API_BASE build arg (not needed, api.ts uses /api relative path)
- Fix Object.entries null crash in DashboardPage
This commit is contained in:
zhi
2026-03-11 10:09:33 +00:00
parent f8fac48fcc
commit c92e399218
4 changed files with 30 additions and 34 deletions

View File

@@ -13,9 +13,10 @@ import ProjectDetailPage from '@/pages/ProjectDetailPage'
import MilestonesPage from '@/pages/MilestonesPage'
import MilestoneDetailPage from '@/pages/MilestoneDetailPage'
import NotificationsPage from '@/pages/NotificationsPage'
import api from '@/services/api'
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}`
type AppState = 'checking' | 'setup' | 'ready'
@@ -23,31 +24,36 @@ export default function App() {
const [appState, setAppState] = useState<AppState>('checking')
const { user, loading, login, logout } = useAuth()
const checkBackend = async () => {
useEffect(() => {
checkInitialized()
}, [])
const checkInitialized = async () => {
try {
await api.get('/health')
setAppState('ready')
const res = await axios.get(`${WIZARD_BASE}/api/v1/config/harborforge.json`, {
timeout: 5000,
})
if (res.data && res.data.initialized === true) {
setAppState('ready')
} else {
setAppState('setup')
}
} catch {
// Wizard unreachable or config doesn't exist → setup needed
setAppState('setup')
}
}
useEffect(() => { checkBackend() }, [])
// Checking backend availability
if (appState === 'checking') {
return <div className="loading">...</div>
return <div className="loading">...</div>
}
// Backend not ready — show setup wizard
if (appState === 'setup') {
return <SetupWizardPage wizardPort={WIZARD_PORT} onComplete={checkBackend} />
return <SetupWizardPage wizardBase={WIZARD_BASE} onComplete={checkInitialized} />
}
// Backend ready but auth loading
if (loading) return <div className="loading">...</div>
// Not logged in
if (!user) {
return (
<BrowserRouter>