update CORS middleware and make it configurable

This commit is contained in:
David Christofas
2021-10-21 15:46:48 +02:00
parent c370276198
commit 9ecc065879
29 changed files with 365 additions and 39 deletions
+9
View File
@@ -33,6 +33,15 @@ func Server(cfg *config.Config) *cli.Command {
if !cfg.Supervised {
return ParseConfig(ctx, cfg)
}
if origins := ctx.StringSlice("cors-allowed-origins"); len(origins) != 0 {
cfg.HTTP.CORS.AllowedOrigins = origins
}
if methods := ctx.StringSlice("cors-allowed-methods"); len(methods) != 0 {
cfg.HTTP.CORS.AllowedMethods = methods
}
if headers := ctx.StringSlice("cors-allowed-headers"); len(headers) != 0 {
cfg.HTTP.CORS.AllowedOrigins = headers
}
logger.Debug().Str("service", "settings").Msg("ignoring config file parsing when running supervised")
return nil
},