Merge pull request #8518 from dragonchaser/cors-issues

[full-ci] adapt cors headers
This commit is contained in:
Christian Richter
2024-03-20 14:43:33 +01:00
committed by GitHub
12 changed files with 71 additions and 16 deletions
@@ -32,7 +32,7 @@ func DefaultConfig() *config.Config {
CacheTTL: 604800, // 7 days
CORS: config.CORS{
AllowedOrigins: []string{"*"},
AllowedOrigins: []string{"https://localhost:9200"},
AllowedMethods: []string{
"OPTIONS",
"HEAD",
@@ -73,7 +73,7 @@ func DefaultConfig() *config.Config {
"Upload-Offset",
"X-HTTP-Method-Override",
},
AllowCredentials: true,
AllowCredentials: false,
},
},
Service: config.Service{
@@ -173,6 +173,13 @@ func EnsureDefaults(cfg *config.Config) {
if cfg.Commons != nil {
cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS
}
if (cfg.Commons != nil && cfg.Commons.OcisURL != "") &&
(cfg.HTTP.CORS.AllowedOrigins == nil ||
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