internal: fix font loading errors on safari
closes #1057 for some reason safari appends the relative font path to the document URL not to the stylesheet URL. Since I don't want to build a fully custom patternfly base css file, this mounts the static files where safari expects them Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
3378e82ec7
commit
7771c0b905
|
@ -1,8 +1,10 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
"goauthentik.io/internal/config"
|
"goauthentik.io/internal/config"
|
||||||
"goauthentik.io/internal/constants"
|
"goauthentik.io/internal/constants"
|
||||||
staticWeb "goauthentik.io/web"
|
staticWeb "goauthentik.io/web"
|
||||||
|
@ -15,22 +17,32 @@ func (ws *WebServer) configureStatic() {
|
||||||
// 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
|
||||||
|
var distFs http.Handler
|
||||||
var authentikHandler http.Handler
|
var authentikHandler http.Handler
|
||||||
var helpHandler http.Handler
|
var helpHandler http.Handler
|
||||||
if config.G.Debug || config.G.Web.LoadLocalFiles {
|
if config.G.Debug || config.G.Web.LoadLocalFiles {
|
||||||
ws.log.Debug("Using local static files")
|
ws.log.Debug("Using local static files")
|
||||||
distHandler = http.StripPrefix("/static/dist/", http.FileServer(http.Dir("./web/dist")))
|
distFs = http.FileServer(http.Dir("./web/dist"))
|
||||||
|
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.StripPrefix("/help/", 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")
|
||||||
distHandler = http.StripPrefix("/static", http.FileServer(http.FS(staticWeb.StaticDist)))
|
distFs = http.FileServer(http.FS(staticWeb.StaticDist))
|
||||||
|
distHandler = http.StripPrefix("/static", distFs)
|
||||||
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)
|
statRouter.PathPrefix("/static/dist/").Handler(distHandler)
|
||||||
statRouter.PathPrefix("/static/authentik/").Handler(authentikHandler)
|
statRouter.PathPrefix("/static/authentik/").Handler(authentikHandler)
|
||||||
|
// 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) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs).ServeHTTP(rw, r)
|
||||||
|
})
|
||||||
|
statRouter.PathPrefix("/if/admin/assets").Handler(http.StripPrefix("/if/admin", distFs))
|
||||||
|
|
||||||
statRouter.PathPrefix("/media/").Handler(http.StripPrefix("/media", fs))
|
statRouter.PathPrefix("/media/").Handler(http.StripPrefix("/media", fs))
|
||||||
|
|
||||||
|
|
Reference in New Issue