adapt cors headers

Signed-off-by: Christian Richter <crichter@owncloud.com>
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Christian Richter
2024-03-19 10:54:58 +01:00
parent 6927fe1afd
commit 72916dc53c
8 changed files with 48 additions and 13 deletions
@@ -29,7 +29,8 @@ func DefaultConfig() *config.Config {
Root: "/",
Namespace: "com.owncloud.web",
CORS: config.CORS{
AllowedOrigins: []string{"*"},
AllowedOrigins: []string{"https://localhost:9200"},
AllowCredentials: false,
},
},
Service: config.Service{
@@ -81,6 +82,11 @@ func EnsureDefaults(cfg *config.Config) {
if cfg.Commons != nil {
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
}
if cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" ||
len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200" {
cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL}
}
}
// Sanitize sanitized the configuration