about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--internal/config/config.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index cab5f90..66e3d82 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -44,6 +44,15 @@ type Config struct {
 	Menus map[string][]MenuItem
 }
 
+func setDevelopmentOverrides(config *Config) error {
+	overrideURL, err := URL.Parse(config.BaseURL, "http://localhost:"+fmt.Sprint(config.Port))
+	if err != nil {
+		return err
+	}
+	config.BaseURL.URL = overrideURL
+	return nil
+}
+
 func GetConfig() (*Config, error) {
 	config := Config{}
 	slog.Debug("reading config.toml")
@@ -59,5 +68,11 @@ func GetConfig() (*Config, error) {
 			return nil, errors.Wrap(err, "config error")
 		}
 	}
+	if os.Getenv("ENV") != "production" {
+		err = setDevelopmentOverrides(&config)
+		if err != nil {
+			return nil, errors.WithMessage(err, "could not override configuration")
+		}
+	}
 	return &config, nil
 }