Skip to content

Commit

Permalink
clash-api: Fix bad redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Aug 23, 2024
1 parent 68ec00a commit 1079686
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions experimental/clashapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 1079686

Please sign in to comment.