diff --git a/backend/internal/api/proxmox.go b/backend/internal/api/proxmox.go index c199e06..a74fd02 100644 --- a/backend/internal/api/proxmox.go +++ b/backend/internal/api/proxmox.go @@ -58,16 +58,14 @@ func (h *ProxmoxHandler) initClient() { log.Printf("[proxmox/init] Impossible de déchiffrer le token : %v", err) return } - log.Printf("[proxmox/init] Client initialisé — url=%s", url) h.client = proxmox.NewClient(url, token) } // GetResources retourne la liste de toutes les ressources Proxmox (LXC + VM + nodes). // GET /api/proxmox/resources func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) { - if h.client == nil { - h.initClient() - } + // Toujours relire la config (prend en compte les mises à jour du token sans redémarrage) + h.initClient() if h.client == nil { JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable) return @@ -86,9 +84,7 @@ func (h *ProxmoxHandler) GetResources(w http.ResponseWriter, r *http.Request) { // GetLXC retourne uniquement les conteneurs LXC. // GET /api/proxmox/lxc func (h *ProxmoxHandler) GetLXC(w http.ResponseWriter, r *http.Request) { - if h.client == nil { - h.initClient() - } + h.initClient() if h.client == nil { JSONError(w, "Proxmox non configuré", http.StatusServiceUnavailable) return