diff --git a/server/channels/api4/config.go b/server/channels/api4/config.go index 5a6946a1ca..1c0707f8c5 100644 --- a/server/channels/api4/config.go +++ b/server/channels/api4/config.go @@ -258,7 +258,9 @@ func getClientConfig(c *Context, w http.ResponseWriter, r *http.Request) { config = c.App.Srv().Platform().ClientConfigWithComputed() } - w.Write([]byte(model.MapToJSON(config))) + if err := json.NewEncoder(w).Encode(config); err != nil { + c.Logger.Warn("Error while writing response", mlog.Err(err)) + } } func getEnvironmentConfig(c *Context, w http.ResponseWriter, r *http.Request) { diff --git a/server/channels/app/platform/config.go b/server/channels/app/platform/config.go index 3411c13bec..5cbf8850b7 100644 --- a/server/channels/app/platform/config.go +++ b/server/channels/app/platform/config.go @@ -13,6 +13,7 @@ import ( "encoding/json" "errors" "fmt" + "maps" "net/http" "reflect" "strconv" @@ -307,10 +308,7 @@ func (ps *PlatformService) EnsureAsymmetricSigningKey() error { // LimitedClientConfigWithComputed gets the configuration in a format suitable for sending to the client. func (ps *PlatformService) LimitedClientConfigWithComputed() map[string]string { - respCfg := map[string]string{} - for k, v := range ps.LimitedClientConfig() { - respCfg[k] = v - } + respCfg := maps.Clone(ps.LimitedClientConfig()) // These properties are not configurable, but nevertheless represent configuration expected // by the client. @@ -321,10 +319,7 @@ func (ps *PlatformService) LimitedClientConfigWithComputed() map[string]string { // ClientConfigWithComputed gets the configuration in a format suitable for sending to the client. func (ps *PlatformService) ClientConfigWithComputed() map[string]string { - respCfg := map[string]string{} - for k, v := range ps.clientConfig.Load().(map[string]string) { - respCfg[k] = v - } + respCfg := maps.Clone(ps.ClientConfig()) // These properties are not configurable, but nevertheless represent configuration expected // by the client. @@ -340,7 +335,6 @@ func (ps *PlatformService) ClientConfigWithComputed() map[string]string { } else { respCfg["SchemaVersion"] = strconv.Itoa(ver) } - return respCfg }