mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
minio-browser: do not redirect to /minio if MINIO_BROWSER=off (#2863)
fixes #2837
This commit is contained in:
parent
64f37bbf5b
commit
bb9be02228
@ -18,6 +18,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -76,19 +77,22 @@ func setBrowserRedirectHandler(h http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h redirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
// Re-direction handled specifically for browsers.
|
if !strings.EqualFold(os.Getenv("MINIO_BROWSER"), "off") {
|
||||||
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && !isRequestSignatureV4(r) {
|
// Re-direction handled specifically for browsers.
|
||||||
// '/' is redirected to 'locationPrefix/'
|
if strings.Contains(r.Header.Get("User-Agent"), "Mozilla") && !isRequestSignatureV4(r) {
|
||||||
// '/webrpc' is redirected to 'locationPrefix/webrpc'
|
// '/' is redirected to 'locationPrefix/'
|
||||||
// '/login' is redirected to 'locationPrefix/login'
|
// '/webrpc' is redirected to 'locationPrefix/webrpc'
|
||||||
switch r.URL.Path {
|
// '/login' is redirected to 'locationPrefix/login'
|
||||||
case "/", "/webrpc", "/login", "/favicon.ico":
|
switch r.URL.Path {
|
||||||
location := h.locationPrefix + r.URL.Path
|
case "/", "/webrpc", "/login", "/favicon.ico":
|
||||||
// Redirect to new location.
|
location := h.locationPrefix + r.URL.Path
|
||||||
http.Redirect(w, r, location, http.StatusTemporaryRedirect)
|
// Redirect to new location.
|
||||||
return
|
http.Redirect(w, r, location, http.StatusTemporaryRedirect)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h.handler.ServeHTTP(w, r)
|
h.handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user