root: allow loading local /static files without debug flag

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-21 21:21:35 +02:00
parent 49def45ca3
commit f6026fdb13
4 changed files with 8 additions and 5 deletions

View File

@ -9,6 +9,7 @@ postgresql:
web:
listen: 0.0.0.0:9000
listen_tls: 0.0.0.0:9443
load_local_files: false
redis:
host: localhost

View File

@ -16,8 +16,9 @@ func DefaultConfig() {
G = Config{
Debug: false,
Web: WebConfig{
Listen: "localhost:9000",
ListenTLS: "localhost:9443",
Listen: "localhost:9000",
ListenTLS: "localhost:9443",
LoadLocalFiles: false,
},
Paths: PathsConfig{
Media: "./media",

View File

@ -9,8 +9,9 @@ type Config struct {
}
type WebConfig struct {
Listen string `yaml:"listen"`
ListenTLS string `yaml:"listen_tls"`
Listen string `yaml:"listen"`
ListenTLS string `yaml:"listen_tls"`
LoadLocalFiles bool `yaml:"load_local_files"`
}
type PathsConfig struct {

View File

@ -10,7 +10,7 @@ import (
func (ws *WebServer) configureStatic() {
statRouter := ws.lh.NewRoute().Subrouter()
if config.G.Debug {
if config.G.Debug || config.G.Web.LoadLocalFiles {
ws.log.Debug("Using local static files")
ws.lh.PathPrefix("/static/dist").Handler(http.StripPrefix("/static/dist", http.FileServer(http.Dir("./web/dist"))))
ws.lh.PathPrefix("/static/authentik").Handler(http.StripPrefix("/static/authentik", http.FileServer(http.Dir("./web/authentik"))))