From a21fa502891a6d2f0600485b1b76762ecc178fd0 Mon Sep 17 00:00:00 2001 From: ivar Date: Fri, 3 Apr 2026 14:28:51 +0200 Subject: fix: resolve Gin routing conflict with catch-all static files handler --- cmd/nebbet/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/nebbet/main.go b/cmd/nebbet/main.go index 8efd504..210ad67 100644 --- a/cmd/nebbet/main.go +++ b/cmd/nebbet/main.go @@ -14,8 +14,11 @@ package main import ( "flag" "fmt" + "net/http" "os" + "github.com/gin-gonic/gin" + "nebbet.no/internal/admin" "nebbet.no/internal/admin/auth" "nebbet.no/internal/builder" @@ -117,8 +120,10 @@ func cmdServe(args []string) { // Serve dependencies (lib/) engine.Static("/lib", "lib") - // Serve static site from public/ - engine.Static("/", outputDir) + // Serve static site as fallback for unmatched routes + engine.NoRoute(func(c *gin.Context) { + http.FileServer(http.Dir(outputDir)).ServeHTTP(c.Writer, c.Request) + }) addr := ":" + *port fmt.Printf("listening on http://localhost%s\n", addr) -- cgit v1.3