diff --git a/cmd/serve/webdav/webdav.go b/cmd/serve/webdav/webdav.go index 00af1f033..cdec88b4b 100644 --- a/cmd/serve/webdav/webdav.go +++ b/cmd/serve/webdav/webdav.go @@ -237,6 +237,9 @@ func (w *WebDAV) ServeHTTP(rw http.ResponseWriter, r *http.Request) { w.serveDir(rw, r, remote) return } + // Add URL Prefix back to path since webdavhandler needs to + // return absolute references. + r.URL.Path = w.opt.HTTP.BaseURL + r.URL.Path w.webdavhandler.ServeHTTP(rw, r) } diff --git a/cmd/serve/webdav/webdav_test.go b/cmd/serve/webdav/webdav_test.go index fa0626075..2bc61a58a 100644 --- a/cmd/serve/webdav/webdav_test.go +++ b/cmd/serve/webdav/webdav_test.go @@ -51,6 +51,7 @@ func TestWebDav(t *testing.T) { start := func(f fs.Fs) (configmap.Simple, func()) { opt := DefaultOpt opt.HTTP.ListenAddr = []string{testBindAddress} + opt.HTTP.BaseURL = "/prefix" opt.Auth.BasicUser = testUser opt.Auth.BasicPass = testPass opt.Template.Path = testTemplate