Skip to content

Commit 7007fec

Browse files
committed
clash-api: Fix bad redirect
1 parent f6a0194 commit 7007fec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

experimental/clashapi/server.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ func authentication(serverSecret string) func(next http.Handler) http.Handler {
277277

278278
func hello(redirect bool) func(w http.ResponseWriter, r *http.Request) {
279279
return func(w http.ResponseWriter, r *http.Request) {
280-
if redirect {
281-
http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect)
282-
} else {
280+
contentType := r.Header.Get("Content-Type")
281+
if !redirect || contentType == "application/json" {
283282
render.JSON(w, r, render.M{"hello": "clash"})
283+
} else {
284+
http.Redirect(w, r, "/ui/", http.StatusTemporaryRedirect)
284285
}
285286
}
286287
}

0 commit comments

Comments
 (0)