internal: fix integrated docs not working

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-11-15 16:13:02 +01:00
parent c43049a981
commit 7cf8a31057
2 changed files with 11 additions and 10 deletions

View file

@ -13,7 +13,8 @@ import (
func (ws *WebServer) configureStatic() { func (ws *WebServer) configureStatic() {
statRouter := ws.lh.NewRoute().Subrouter() statRouter := ws.lh.NewRoute().Subrouter()
statRouter.Use(disableIndex) indexLessRouter := statRouter.NewRoute().Subrouter()
indexLessRouter.Use(disableIndex)
// Media files, always local // Media files, always local
fs := http.FileServer(http.Dir(config.G.Paths.Media)) fs := http.FileServer(http.Dir(config.G.Paths.Media))
var distHandler http.Handler var distHandler http.Handler
@ -25,7 +26,7 @@ func (ws *WebServer) configureStatic() {
distFs = http.FileServer(http.Dir("./web/dist")) distFs = http.FileServer(http.Dir("./web/dist"))
distHandler = http.StripPrefix("/static/dist/", distFs) distHandler = http.StripPrefix("/static/dist/", distFs)
authentikHandler = http.StripPrefix("/static/authentik/", http.FileServer(http.Dir("./web/authentik"))) authentikHandler = http.StripPrefix("/static/authentik/", http.FileServer(http.Dir("./web/authentik")))
helpHandler = http.StripPrefix("/help/", http.FileServer(http.Dir("./website/help"))) helpHandler = http.FileServer(http.Dir("./website/help/"))
} else { } else {
statRouter.Use(ws.staticHeaderMiddleware) statRouter.Use(ws.staticHeaderMiddleware)
ws.log.Debug("Using packaged static files with aggressive caching") ws.log.Debug("Using packaged static files with aggressive caching")
@ -34,21 +35,21 @@ func (ws *WebServer) configureStatic() {
authentikHandler = http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticAuthentik))) authentikHandler = http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticAuthentik)))
helpHandler = http.FileServer(http.FS(staticDocs.Help)) helpHandler = http.FileServer(http.FS(staticDocs.Help))
} }
statRouter.PathPrefix("/static/dist/").Handler(distHandler) indexLessRouter.PathPrefix("/static/dist/").Handler(distHandler)
statRouter.PathPrefix("/static/authentik/").Handler(authentikHandler) indexLessRouter.PathPrefix("/static/authentik/").Handler(authentikHandler)
// Prevent font-loading issues on safari, which loads fonts relatively to the URL the browser is on // Prevent font-loading issues on safari, which loads fonts relatively to the URL the browser is on
statRouter.PathPrefix("/if/flow/{flow_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { indexLessRouter.PathPrefix("/if/flow/{flow_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r) vars := mux.Vars(r)
disableIndex(http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs)).ServeHTTP(rw, r) disableIndex(http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs)).ServeHTTP(rw, r)
}) })
statRouter.PathPrefix("/if/admin/assets").Handler(disableIndex(http.StripPrefix("/if/admin", distFs))) indexLessRouter.PathPrefix("/if/admin/assets").Handler(http.StripPrefix("/if/admin", distFs))
statRouter.PathPrefix("/if/user/assets").Handler(disableIndex(http.StripPrefix("/if/user", distFs))) indexLessRouter.PathPrefix("/if/user/assets").Handler(http.StripPrefix("/if/user", distFs))
statRouter.PathPrefix("/media/").Handler(http.StripPrefix("/media", fs)) indexLessRouter.PathPrefix("/media/").Handler(http.StripPrefix("/media", fs))
statRouter.PathPrefix("/if/help/").Handler(helpHandler) statRouter.PathPrefix("/if/help/").Handler(http.StripPrefix("/if/help/", helpHandler))
statRouter.PathPrefix("/help").Handler(http.RedirectHandler("/if/help/", http.StatusMovedPermanently)) statRouter.PathPrefix("/help").Handler(http.RedirectHandler("/if/help/", http.StatusMovedPermanently))
ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { ws.lh.Path("/robots.txt").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {

View file

@ -4,7 +4,7 @@ module.exports = {
title: "authentik", title: "authentik",
tagline: "Making authentication simple.", tagline: "Making authentication simple.",
url: "https://goauthentik.io", url: "https://goauthentik.io",
baseUrl: "/help/", baseUrl: "/if/help/",
onBrokenLinks: "throw", onBrokenLinks: "throw",
favicon: "img/icon.png", favicon: "img/icon.png",
organizationName: "BeryJu", organizationName: "BeryJu",