React Router fixes for Console (#336)

- Adding protectedRoute component
- Removed unnecessary redirect login
This commit is contained in:
Lenin Alevski
2020-10-21 13:13:40 -07:00
committed by GitHub
parent 7e9d581277
commit 0c43e5c3f4
4 changed files with 128 additions and 133 deletions

View File

@@ -19,10 +19,12 @@
package restapi
import (
"bytes"
"crypto/tls"
"log"
"net/http"
"strings"
"time"
"github.com/minio/console/pkg/auth"
@@ -229,8 +231,9 @@ func wrapHandlerSinglePageApplication(h http.Handler) http.HandlerFunc {
nfrw := &notFoundRedirectRespWr{ResponseWriter: w}
h.ServeHTTP(nfrw, r)
if nfrw.status == 404 {
log.Printf("Redirecting %s to index.html.", r.RequestURI)
http.Redirect(w, r, "/index.html", http.StatusFound)
indexPage, _ := portalUI.Asset("build/index.html")
w.Header().Set("Content-Type", "text/html; charset=utf-8")
http.ServeContent(w, r, "index.html", time.Now(), bytes.NewReader(indexPage))
}
}
}