Skip to content

Commit

Permalink
config for filebrowser proxy path
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Oct 17, 2024
1 parent aee8773 commit e29f604
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Config struct {
Servername string
EnabledFeatures []string
FilebrowserURL string
FilebrowserProxyPath string
InstallMtuiMod bool
AutoReconfigureMods bool
LogStreamURL string
Expand Down Expand Up @@ -50,6 +51,7 @@ func NewConfig(world_dir string) *Config {
Servername: os.Getenv("SERVER_NAME"),
EnabledFeatures: strings.Split(os.Getenv("ENABLE_FEATURES"), ","),
FilebrowserURL: os.Getenv("FILEBROWSER_URL"),
FilebrowserProxyPath: os.Getenv("FILEBROWSER_PROXY_PATH"),
InstallMtuiMod: os.Getenv("INSTALL_MTUI_MOD") == "true",
AutoReconfigureMods: os.Getenv("AUTORECONFIGURE_MODS") == "true",
LogStreamURL: os.Getenv("LOG_STREAM_URL"),
Expand Down
5 changes: 4 additions & 1 deletion web/setup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package web

import (
"fmt"
"mtui/app"
"mtui/public"
"mtui/types"
Expand Down Expand Up @@ -34,12 +35,14 @@ func Setup(a *app.App) error {
// enable filebrowser access with "server" priv
remote, err := url.Parse(a.Config.FilebrowserURL)
if err != nil {
panic(err)
return err
}

handler := func(p *httputil.ReverseProxy) func(http.ResponseWriter, *http.Request) {
return api.SecurePriv("server", func(w http.ResponseWriter, r *http.Request, c *types.Claims) {
r.Host = remote.Host
// prepend proxy path
r.URL.Path = fmt.Sprintf("%s%s", a.Config.FilebrowserProxyPath, r.URL.Path)
p.ServeHTTP(w, r)
})
}
Expand Down

0 comments on commit e29f604

Please sign in to comment.