[BUGFIX] Add routes for files in the root path (#988)

pull/991/head
Amir Zarrinkafsh 2020-05-07 21:29:12 +10:00 committed by GitHub
parent 6aa97fa56b
commit a70e460ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
func StartServer(configuration schema.Configuration, providers middlewares.Providers) {
autheliaMiddleware := middlewares.AutheliaMiddleware(configuration, providers)
embeddedAssets := "/public_html"
rootFiles := []string{"favicon.ico", "manifest.json", "robots.txt"}
// TODO: Remove in v4.18.0.
if os.Getenv("PUBLIC_DIR") != "" {
logging.Logger().Warn("PUBLIC_DIR environment variable has been deprecated, assets are now embedded.")
@ -30,6 +31,11 @@ func StartServer(configuration schema.Configuration, providers middlewares.Provi
router := router.New()
router.GET("/", ServeIndex(embeddedAssets))
for _, f := range rootFiles {
router.GET("/"+f, fasthttpadaptor.NewFastHTTPHandler(br.Serve(embeddedAssets)))
}
router.GET("/static/{filepath:*}", fasthttpadaptor.NewFastHTTPHandler(br.Serve(embeddedAssets)))
router.GET("/api/state", autheliaMiddleware(handlers.StateGet))