Skip to content

Commit

Permalink
fixed: middleware issue while serving static file
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu-allen committed Oct 18, 2024
1 parent 68e87b3 commit d5b34dd
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pkg/config/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ func createCORSMiddleware() negroni.Handler {

// applyStaticFileMiddleware handles static files and Vue.js routing
func applyStaticFileMiddleware(n *negroni.Negroni) {
n.Use(&negroni.Static{
Dir: http.Dir("./browser/flagr-ui/dist/"),
Prefix: Config.WebPrefix,
IndexFile: "index.html",
})

n.UseFunc(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
if strings.Contains(r.URL.Path, "/api/") {
next(w, r)
Expand All @@ -133,7 +127,7 @@ func applyStaticFileMiddleware(n *negroni.Negroni) {

filePath := "./browser/flagr-ui/dist/" + r.URL.Path
if _, err := os.Stat(filePath); err == nil && filepath.Ext(r.URL.Path) != "" {
next(w, r) // Serve the static file if it exists
http.ServeFile(w, r, filePath) // Serve the static file directly
return
}

Expand Down

0 comments on commit d5b34dd

Please sign in to comment.