From 9f0aa55be67b7a09810569250563bb388b40590a Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Thu, 9 Oct 2025 20:27:15 +0200 Subject: [PATCH] fix: ignore trailing slash in URL --- backend/frontend/frontend_included.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/frontend/frontend_included.go b/backend/frontend/frontend_included.go index 064ab8d4..504a0ba1 100644 --- a/backend/frontend/frontend_included.go +++ b/backend/frontend/frontend_included.go @@ -75,6 +75,11 @@ func RegisterFrontend(router *gin.Engine) error { router.NoRoute(func(c *gin.Context) { path := strings.TrimPrefix(c.Request.URL.Path, "/") + if strings.HasSuffix(path, "/") { + c.Redirect(http.StatusMovedPermanently, strings.TrimRight(c.Request.URL.String(), "/")) + return + } + if strings.HasPrefix(path, "api/") { c.JSON(http.StatusNotFound, gin.H{"error": "API endpoint not found"}) return @@ -94,13 +99,9 @@ func RegisterFrontend(router *gin.Engine) error { c.Header("Content-Type", "text/html; charset=utf-8") c.Header("Cache-Control", "no-store") c.Status(http.StatusOK) - - err = writeIndexFn(c.Writer, nonce) - if err != nil { + if err := writeIndexFn(c.Writer, nonce); err != nil { _ = c.Error(fmt.Errorf("failed to write index.html file: %w", err)) - return } - return }