Add default value to AllowCorsFrom setting
Этот коммит содержится в:
@@ -166,8 +166,8 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
// All api response bodies will be JSON formatted by default
|
// All api response bodies will be JSON formatted by default
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
if len(utils.Cfg.ServiceSettings.AllowCorsFrom) > 0 {
|
if len(*utils.Cfg.ServiceSettings.AllowCorsFrom) > 0 {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", utils.Cfg.ServiceSettings.AllowCorsFrom)
|
w.Header().Set("Access-Control-Allow-Origin", *utils.Cfg.ServiceSettings.AllowCorsFrom)
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Method == "GET" {
|
if r.Method == "GET" {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ type ServiceSettings struct {
|
|||||||
EnableDeveloper *bool
|
EnableDeveloper *bool
|
||||||
EnableSecurityFixAlert *bool
|
EnableSecurityFixAlert *bool
|
||||||
EnableInsecureOutgoingConnections *bool
|
EnableInsecureOutgoingConnections *bool
|
||||||
AllowCorsFrom string
|
AllowCorsFrom *string
|
||||||
SessionLengthWebInDays *int
|
SessionLengthWebInDays *int
|
||||||
SessionLengthMobileInDays *int
|
SessionLengthMobileInDays *int
|
||||||
SessionLengthSSOInDays *int
|
SessionLengthSSOInDays *int
|
||||||
@@ -378,6 +378,11 @@ func (o *Config) SetDefaults() {
|
|||||||
o.ServiceSettings.WebsocketSecurePort = new(int)
|
o.ServiceSettings.WebsocketSecurePort = new(int)
|
||||||
*o.ServiceSettings.WebsocketSecurePort = 443
|
*o.ServiceSettings.WebsocketSecurePort = 443
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if o.ServiceSettings.AllowCorsFrom == nil {
|
||||||
|
o.ServiceSettings.AllowCorsFrom = new(string)
|
||||||
|
*o.ServiceSettings.AllowCorsFrom = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Config) IsValid() *AppError {
|
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["WebsocketPort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketPort)
|
||||||
props["WebsocketSecurePort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketSecurePort)
|
props["WebsocketSecurePort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketSecurePort)
|
||||||
|
|
||||||
props["AllowCorsFrom"] = c.ServiceSettings.AllowCorsFrom
|
props["AllowCorsFrom"] = *c.ServiceSettings.AllowCorsFrom
|
||||||
|
|
||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user