clash-api: Fix bad redirect

This commit is contained in:
世界 2024-08-23 13:38:27 +08:00
parent f57dda20f5
commit 379e14dbdc
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4

View File

@ -277,10 +277,11 @@ func authentication(serverSecret string) func(next http.Handler) http.Handler {
func hello(redirect bool) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
if redirect {
http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect)
} else {
contentType := r.Header.Get("Content-Type")
if !redirect || contentType == "application/json" {
render.JSON(w, r, render.M{"hello": "clash"})
} else {
http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect)
}
}
}