From d91008c3c2821dbba171e936e97b043f5e22861d Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 20 Nov 2020 10:47:17 +0100 Subject: [PATCH 1/2] Serve index.html in static middleware --- ocis-pkg/middleware/static.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ocis-pkg/middleware/static.go b/ocis-pkg/middleware/static.go index 718dd84354f..57f2e695707 100644 --- a/ocis-pkg/middleware/static.go +++ b/ocis-pkg/middleware/static.go @@ -30,14 +30,10 @@ func Static(root string, fs http.FileSystem, ttl int) func(http.Handler) http.Ha if strings.HasPrefix(r.URL.Path, path.Join(root, "api")) { next.ServeHTTP(w, r) } else { - if strings.HasSuffix(r.URL.Path, "/") { - http.NotFound(w, r) - } else { - w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl))) - w.Header().Set("Last-Modified", lastModified) - w.Header().Del("Expires") - static.ServeHTTP(w, r) - } + w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl))) + w.Header().Set("Last-Modified", lastModified) + w.Header().Del("Expires") + static.ServeHTTP(w, r) } }) } From 54f9505787f41764af868beef311a70bdd962fa8 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Fri, 20 Nov 2020 10:51:41 +0100 Subject: [PATCH 2/2] Add changelog --- changelog/unreleased/pkg-serve-index-html.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 changelog/unreleased/pkg-serve-index-html.md diff --git a/changelog/unreleased/pkg-serve-index-html.md b/changelog/unreleased/pkg-serve-index-html.md new file mode 100644 index 00000000000..24008e7d954 --- /dev/null +++ b/changelog/unreleased/pkg-serve-index-html.md @@ -0,0 +1,6 @@ +Bugfix: Serve index.html for directories + +The static middleware in ocis-pkg now serves index.html instead of returning 404 on paths with a trailing `/`. + +https://github.com/owncloud/ocis/pull/912 +https://github.com/owncloud/ocis-pkg/issues/63