From 7b01b1b928423514c57fd63f28eb02dbfb581c3c Mon Sep 17 00:00:00 2001 From: cangui Date: Mon, 18 Aug 2025 19:14:24 +0200 Subject: [PATCH] UP --- main.go | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 47c35a3..356ad2e 100644 --- a/main.go +++ b/main.go @@ -233,24 +233,28 @@ func startSFTPServer(base string) { // ---------- HTTP (Gin) ---------- func startHTTP() { - bd := db.InitDB() - app := gin.Default() + bd := db.InitDB() + app := gin.Default() - api := app.Group("/api/v1") - routes.AddRoutes(api, bd) - utils.CreateDefaultFolder(bd) + api := app.Group("/api/v1") + routes.AddRoutes(api, bd) + utils.CreateDefaultFolder(bd) - app.Static("/static", "./web") - app.NoRoute(func(c *gin.Context) { - if strings.HasPrefix(c.Request.URL.Path, "/api/") { - c.JSON(404, gin.H{"error": "Not found"}) - return - } - c.File("./web/index.html") - }) + // Sert tout le dossier /app/web à la racine + app.StaticFS("/", gin.Dir("./web", true)) - log.Println("[HTTP] Serveur Gin sur http://0.0.0.0:8080") - _ = app.Run(":8080") + // (Optionnel) fallback SPA si tu as un router côté front + app.NoRoute(func(c *gin.Context) { + // Laisse passer les 404 d'API + if strings.HasPrefix(c.Request.URL.Path, "/api/") { + c.JSON(404, gin.H{"error": "Not found"}) + return + } + c.File("./web/index.html") + }) + + log.Println("[HTTP] Serveur Gin sur http://0.0.0.0:8080") + _ = app.Run(":8080") } func main() {