fix(proxy): ignore Referer if got redirect (close #3996)

This commit is contained in:
Andy Hsu
2023-03-31 20:29:55 +08:00
parent 0c5820a98f
commit 3b07c72f88
2 changed files with 12 additions and 29 deletions

View File

@ -16,7 +16,15 @@ import (
log "github.com/sirupsen/logrus"
)
var HttpClient = &http.Client{}
var HttpClient = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return errors.New("stopped after 10 redirects")
}
req.Header.Del("Referer")
return nil
},
}
func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.Obj) error {
// read data with native