From 641fec12157504b8ed2935ba9943828662a725f9 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 13 Feb 2024 10:05:15 +0100 Subject: [PATCH] fix: never return frontend on routes starting with /api This fixes a problem where Vikunja would sometimes return the html for the frontend when accessing an api route for a nonexistent ressource, because the static handler was the next best. Resolves https://kolaente.dev/vikunja/vikunja/issues/2110 --- pkg/routes/static.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/routes/static.go b/pkg/routes/static.go index d4f341424..453b9345b 100644 --- a/pkg/routes/static.go +++ b/pkg/routes/static.go @@ -141,6 +141,9 @@ func static() echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) (err error) { p := c.Request().URL.Path + if strings.HasPrefix(p, "/api/") { + return next(c) + } if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`. p = c.Param("*") }