Skip to content

Commit

Permalink
Fix: frontend does not work when request path is not clean (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd authored Nov 20, 2024
1 parent 1fb26a3 commit 10b0c69
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/frontend/middleware/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package middleware
import (
"context"
"net/http"
"path"
"strings"

"github.com/dagu-org/dagu/internal/logger"
Expand Down Expand Up @@ -45,6 +46,7 @@ func SetupGlobalMiddleware(handler http.Handler) http.Handler {
)(next)
}
next = prefixChecker(next)
next = cleanPath(next)

return next
}
Expand Down Expand Up @@ -124,6 +126,14 @@ func prefixChecker(next http.Handler) http.Handler {
})
}

func cleanPath(h http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
r.URL.Path = path.Clean(r.URL.Path)
h.ServeHTTP(w, r)
})
}

func cors(h http.Handler) http.Handler {
return http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 10b0c69

Please sign in to comment.