root: allow loading local /static files without debug flag
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		@ -9,6 +9,7 @@ postgresql:
 | 
				
			|||||||
web:
 | 
					web:
 | 
				
			||||||
  listen: 0.0.0.0:9000
 | 
					  listen: 0.0.0.0:9000
 | 
				
			||||||
  listen_tls: 0.0.0.0:9443
 | 
					  listen_tls: 0.0.0.0:9443
 | 
				
			||||||
 | 
					  load_local_files: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
redis:
 | 
					redis:
 | 
				
			||||||
  host: localhost
 | 
					  host: localhost
 | 
				
			||||||
 | 
				
			|||||||
@ -16,8 +16,9 @@ func DefaultConfig() {
 | 
				
			|||||||
	G = Config{
 | 
						G = Config{
 | 
				
			||||||
		Debug: false,
 | 
							Debug: false,
 | 
				
			||||||
		Web: WebConfig{
 | 
							Web: WebConfig{
 | 
				
			||||||
			Listen:    "localhost:9000",
 | 
								Listen:         "localhost:9000",
 | 
				
			||||||
			ListenTLS: "localhost:9443",
 | 
								ListenTLS:      "localhost:9443",
 | 
				
			||||||
 | 
								LoadLocalFiles: false,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Paths: PathsConfig{
 | 
							Paths: PathsConfig{
 | 
				
			||||||
			Media: "./media",
 | 
								Media: "./media",
 | 
				
			||||||
 | 
				
			|||||||
@ -9,8 +9,9 @@ type Config struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type WebConfig struct {
 | 
					type WebConfig struct {
 | 
				
			||||||
	Listen    string `yaml:"listen"`
 | 
						Listen         string `yaml:"listen"`
 | 
				
			||||||
	ListenTLS string `yaml:"listen_tls"`
 | 
						ListenTLS      string `yaml:"listen_tls"`
 | 
				
			||||||
 | 
						LoadLocalFiles bool   `yaml:"load_local_files"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type PathsConfig struct {
 | 
					type PathsConfig struct {
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (ws *WebServer) configureStatic() {
 | 
					func (ws *WebServer) configureStatic() {
 | 
				
			||||||
	statRouter := ws.lh.NewRoute().Subrouter()
 | 
						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.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/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"))))
 | 
							ws.lh.PathPrefix("/static/authentik").Handler(http.StripPrefix("/static/authentik", http.FileServer(http.Dir("./web/authentik"))))
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user