diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go index 2983a57d7..1e27ecb76 100644 --- a/backend/cmd/api/main.go +++ b/backend/cmd/api/main.go @@ -63,8 +63,11 @@ func main() { }(cfg.Metrics.Address) } - ratelimit.Init() - router.Use(ratelimit.HttpMiddleware) + if cfg.Frontend.RatelimitEnabled { + log.Infof("enabling ratelimit") + ratelimit.Init() + router.Use(ratelimit.HttpMiddleware) + } srv := &http.Server{ Handler: router, diff --git a/backend/pkg/commons/types/config.go b/backend/pkg/commons/types/config.go index 95b5dbc9a..943bfb4aa 100644 --- a/backend/pkg/commons/types/config.go +++ b/backend/pkg/commons/types/config.go @@ -212,6 +212,7 @@ type Config struct { DiamondMonth int `yaml:"diamondMonth" envconfig:"FRONTEND_RATELIMITS_DIAMOND_MONTH"` } `yaml:"ratelimits"` RatelimitUpdateInterval time.Duration `yaml:"ratelimitUpdateInterval" envconfig:"FRONTEND_RATELIMIT_UPDATE_INTERVAL"` + RatelimitEnabled bool `yaml:"ratelimitEnabled" envconfig:"FRONTEND_RATELIMIT_ENABLED"` SessionSecret string `yaml:"sessionSecret" envconfig:"FRONTEND_SESSION_SECRET"` SessionSameSiteNone bool `yaml:"sessionSameSiteNone" envconfig:"FRONTEND_SESSION_SAMESITE_NONE"` SessionCookieDomain string `yaml:"sessionCookieDomain" envconfig:"FRONTEND_SESSION_COOKIE_DOMAIN"`