diff --git a/fs/rc/rcserver/rcserver.go b/fs/rc/rcserver/rcserver.go index ac24c6152..edda4d94d 100644 --- a/fs/rc/rcserver/rcserver.go +++ b/fs/rc/rcserver/rcserver.go @@ -14,6 +14,7 @@ import ( "regexp" "sort" "strings" + "sync" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -34,6 +35,7 @@ import ( ) var promHandler http.Handler +var onlyOnceWarningAllowOrigin sync.Once func init() { rcloneCollector := accounting.NewRcloneCollector() @@ -187,9 +189,11 @@ func (s *Server) handler(w http.ResponseWriter, r *http.Request) { allowOrigin := rcflags.Opt.AccessControlAllowOrigin if allowOrigin != "" { - if allowOrigin == "*" { - fs.Logf(nil, "Warning: Allow origin set to *. This can cause serious security problems.") - } + onlyOnceWarningAllowOrigin.Do(func() { + if allowOrigin == "*" { + fs.Logf(nil, "Warning: Allow origin set to *. This can cause serious security problems.") + } + }) w.Header().Add("Access-Control-Allow-Origin", allowOrigin) } else { w.Header().Add("Access-Control-Allow-Origin", s.URL())