mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Add default value to AllowCorsFrom setting
This commit is contained in:
@@ -166,8 +166,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// All api response bodies will be JSON formatted by default
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
if len(utils.Cfg.ServiceSettings.AllowCorsFrom) > 0 {
|
||||
w.Header().Set("Access-Control-Allow-Origin", utils.Cfg.ServiceSettings.AllowCorsFrom)
|
||||
if len(*utils.Cfg.ServiceSettings.AllowCorsFrom) > 0 {
|
||||
w.Header().Set("Access-Control-Allow-Origin", *utils.Cfg.ServiceSettings.AllowCorsFrom)
|
||||
}
|
||||
|
||||
if r.Method == "GET" {
|
||||
|
||||
@@ -39,7 +39,7 @@ type ServiceSettings struct {
|
||||
EnableDeveloper *bool
|
||||
EnableSecurityFixAlert *bool
|
||||
EnableInsecureOutgoingConnections *bool
|
||||
AllowCorsFrom string
|
||||
AllowCorsFrom *string
|
||||
SessionLengthWebInDays *int
|
||||
SessionLengthMobileInDays *int
|
||||
SessionLengthSSOInDays *int
|
||||
@@ -378,6 +378,11 @@ func (o *Config) SetDefaults() {
|
||||
o.ServiceSettings.WebsocketSecurePort = new(int)
|
||||
*o.ServiceSettings.WebsocketSecurePort = 443
|
||||
}
|
||||
|
||||
if o.ServiceSettings.AllowCorsFrom == nil {
|
||||
o.ServiceSettings.AllowCorsFrom = new(string)
|
||||
*o.ServiceSettings.AllowCorsFrom = ""
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Config) IsValid() *AppError {
|
||||
|
||||
@@ -236,7 +236,7 @@ func getClientConfig(c *model.Config) map[string]string {
|
||||
props["WebsocketPort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketPort)
|
||||
props["WebsocketSecurePort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketSecurePort)
|
||||
|
||||
props["AllowCorsFrom"] = c.ServiceSettings.AllowCorsFrom
|
||||
props["AllowCorsFrom"] = *c.ServiceSettings.AllowCorsFrom
|
||||
|
||||
return props
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user