From 4b083f6fa539123c444d6f5beb9ee5bcbb6ad051 Mon Sep 17 00:00:00 2001 From: enzo Date: Sun, 22 Mar 2026 17:08:43 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20store=20fetch=20c=C3=B4t=C3=A9=20navigat?= =?UTF-8?q?eur=20(backend=20sans=20internet)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le container backend n'a pas accès sortant vers git.geronzi.fr. loadStore() appelle maintenant directement l'API Forgejo depuis le navigateur (qui a internet). Le backend n'est plus sollicité que pour l'installation (POST /api/registry/modules/:id/install). Co-Authored-By: Claude Sonnet 4.6 --- frontend/js/app.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/frontend/js/app.js b/frontend/js/app.js index ca82bb0..632a5ae 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -1087,7 +1087,8 @@ document.addEventListener('alpine:init', () => { _pollTimer: null, async init() { - await Promise.all([this.load(), this.loadStore()]) + await this.load() // modules installés d'abord (loadStore en a besoin) + await this.loadStore() }, destroy() { @@ -1107,17 +1108,27 @@ document.addEventListener('alpine:init', () => { async loadStore() { this.storeLoading = true this.storeError = '' + // Fetch directement depuis le navigateur (le backend n'a pas forcément accès internet) + const FORGEJO_URL = 'https://git.geronzi.fr' + const FORGEJO_ORG = 'proxmoxPanel' try { - const res = await apiFetch('/api/registry/modules') - if (res.ok) { - // L'API retourne { modules: [...], error: "..." } - const data = await res.json() - this.storeModules = data.modules || [] - if (data.error) this.storeError = data.error - } else { - this.storeError = `Erreur serveur (HTTP ${res.status})` + const res = await fetch(`${FORGEJO_URL}/api/v1/orgs/${FORGEJO_ORG}/repos?limit=50`) + if (!res.ok) { + this.storeError = `Erreur Forgejo (HTTP ${res.status})` this.storeModules = [] + return } + const repos = await res.json() + const exclude = new Set(['core']) + const installedIDs = new Set(this.modules.map(m => m.id)) + this.storeModules = repos + .filter(r => !exclude.has(r.name)) + .map(r => ({ + id: r.name, + description: r.description || '', + repo_url: r.html_url, + installed: installedIDs.has(r.name), + })) } catch(e) { this.storeError = 'Impossible de joindre le store : ' + e.message this.storeModules = []