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
This commit is contained in:
parent
18374c2e52
commit
641fec1215
@ -141,6 +141,9 @@ func static() echo.MiddlewareFunc {
|
|||||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) (err error) {
|
return func(c echo.Context) (err error) {
|
||||||
p := c.Request().URL.Path
|
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*`.
|
if strings.HasSuffix(c.Path(), "*") { // When serving from a group, e.g. `/static*`.
|
||||||
p = c.Param("*")
|
p = c.Param("*")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user