diff options
| author | ivar <i@oiee.no> | 2026-04-03 14:28:51 +0200 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2026-04-03 14:28:51 +0200 |
| commit | a21fa502891a6d2f0600485b1b76762ecc178fd0 (patch) | |
| tree | a719f5887a91c970e8407aa563d694260ba361db | |
| parent | dfa5b9d69308af36a53c66d6c5a3e9b735f0c6a9 (diff) | |
| download | nebbet.no-a21fa502891a6d2f0600485b1b76762ecc178fd0.tar.xz nebbet.no-a21fa502891a6d2f0600485b1b76762ecc178fd0.zip | |
fix: resolve Gin routing conflict with catch-all static files handler
| -rw-r--r-- | cmd/nebbet/main.go | 9 |
1 files 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) |
