diff options
Diffstat (limited to 'internal/server')
-rw-r--r-- | internal/server/server.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/internal/server/server.go b/internal/server/server.go index 11747ea..b35b6dd 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "net/http" + "net/url" "os" "slices" "time" @@ -38,9 +39,15 @@ type Server struct { *http.Server } -func applyDevModeOverrides(config *cfg.Config) { +func applyDevModeOverrides(config *cfg.Config, listenAddress string) { config.CSP.ScriptSrc = slices.Insert(config.CSP.ScriptSrc, 0, "'unsafe-inline'") config.CSP.ConnectSrc = slices.Insert(config.CSP.ConnectSrc, 0, "'self'") + config.BaseURL = cfg.URL{ + URL: &url.URL{ + Scheme: "http", + Host: listenAddress, + }, + } } func serverHeaderHandler(wrappedHandler http.Handler) http.Handler { @@ -56,15 +63,14 @@ func New(runtimeConfig *Config) (*Server, error) { if err != nil { return nil, errors.WithMessage(err, "error parsing configuration file") } - if runtimeConfig.InDevServer { - applyDevModeOverrides(config) - } listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, runtimeConfig.Port) env := "development" if runtimeConfig.Production { env = "production" + } else { + applyDevModeOverrides(config, listenAddress) } err = sentry.Init(sentry.ClientOptions{ EnableTracing: true, |