From 5798132e9b47b7e2384f84b4518ebc8b1390f45c Mon Sep 17 00:00:00 2001 From: Settel Date: Wed, 9 Mar 2022 09:09:04 +0100 Subject: [PATCH] fix: workaround for routes like /play, /admin which really should have a trailing / --- server/src/handler/filehandler.go | 8 ++++++++ server/src/resources/dist-build.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/handler/filehandler.go b/server/src/handler/filehandler.go index 168a942..45b5c0a 100644 --- a/server/src/handler/filehandler.go +++ b/server/src/handler/filehandler.go @@ -15,6 +15,14 @@ func FileHandler(w http.ResponseWriter, req *http.Request) { } uri = uri[1:] data, err := Resources.Asset(uri) + if err != nil && uri[len(uri)-1] != '/' { + // workaround for routes like "/play" which really should be "/play/index.html" + uriFolder := uri + "/index.html" + data, err = Resources.Asset(uriFolder) + if err == nil { + uri = uriFolder + } + } if err != nil { fmt.Printf("%s: %v\n", uri, err) http.NotFoundHandler().ServeHTTP(w, req) diff --git a/server/src/resources/dist-build.go b/server/src/resources/dist-build.go index 9cda25e..c4ec58a 100644 --- a/server/src/resources/dist-build.go +++ b/server/src/resources/dist-build.go @@ -1,3 +1,3 @@ package Resources -//go:generate go-bindata -pkg Resources -o dist-generated.go --prefix ../../../client/dist/ ../../../client/dist/ ../../../client/dist/_nuxt/ ../../../client/dist/play ../../../client/dist/admin ../../../client/dist/fonts/dosis ../../../client/dist/fonts/wendy-one +//go:generate go-bindata -pkg Resources -o dist-generated.go --prefix ../../../client/dist/ ../../../client/dist/ ../../../client/dist/_nuxt/ ../../../client/dist/play/ ../../../client/dist/admin/ ../../../client/dist/fonts/dosis ../../../client/dist/fonts/wendy-one