Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: Skip auth for OPTIONS request

Nick Craig-Wood550ab441c541
diff --git a/cmd/serve/httplib/httplib.go b/cmd/serve/httplib/httplib.go
index 2844b7c40..ccbf4647e 100644
--- a/cmd/serve/httplib/httplib.go
+++ b/cmd/serve/httplib/httplib.go
@@ -150,6 +150,11 @@ func NewServer(handler http.Handler, opt *Options) *Server {
authenticator := auth.NewBasicAuthenticator(s.Opt.Realm, secretProvider)
oldHandler := handler
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ // No auth wanted for OPTIONS method
+ if r.Method == "OPTIONS" {
+ oldHandler.ServeHTTP(w, r)
+ return
+ }
if username := authenticator.CheckAuth(r); username == "" {
authHeader := r.Header.Get(authenticator.Headers.V().Authorization)
if authHeader != "" {