fix: update CORS handling to log warnings for wildcard usage and disable cors by default. (#674)

This commit is contained in:
Miroslav Šedivý
2026-08-05 16:28:42 +02:00
committed by GitHub
parent 165bf575c4
commit bce6c57b6a
+4 -2
View File
@@ -120,8 +120,9 @@ func (s *Server) Set() {
s.Metrics = viper.GetBool("server.metrics")
s.CORS = viper.GetStringSlice("server.cors")
if len(s.CORS) == 0 || slices.Contains(s.CORS, "*") {
if slices.Contains(s.CORS, "*") {
s.CORS = []string{"*"}
log.Warn().Msg("CORS is enabled for all origins, this is not recommended for production environments")
}
}
@@ -160,8 +161,9 @@ func (s *Server) SetV2() {
}
if viper.IsSet("cors") {
s.CORS = viper.GetStringSlice("cors")
if len(s.CORS) == 0 || slices.Contains(s.CORS, "*") {
if slices.Contains(s.CORS, "*") {
s.CORS = []string{"*"}
log.Warn().Msg("CORS is enabled for all origins, this is not recommended for production environments")
}
log.Warn().Msg("you are using v2 configuration 'NEKO_CORS' which is deprecated, please use 'NEKO_SERVER_CORS' instead")
enableLegacy = true