diff --git a/ee/tabby-webserver/src/rate_limit.rs b/ee/tabby-webserver/src/rate_limit.rs index c85bd5f7c8c3..ddbc0f5b0352 100644 --- a/ee/tabby-webserver/src/rate_limit.rs +++ b/ee/tabby-webserver/src/rate_limit.rs @@ -20,7 +20,12 @@ impl Default for UserRateLimiter { } impl UserRateLimiter { - pub async fn is_allowed(&self, user_id: &str) -> bool { + pub async fn is_allowed(&self, uri: &axum::http::Uri, user_id: &str) -> bool { + // Do not limit health check requests. + if uri.path().ends_with("/v1/health") || uri.path().ends_with("/v1beta/health") { + return true + } + let mut rate_limiters = self.rate_limiters.lock().await; let rate_limiter = rate_limiters.cache_get_or_set_with(user_id.to_string(), || { // Create a new rate limiter for this user. diff --git a/ee/tabby-webserver/src/service/mod.rs b/ee/tabby-webserver/src/service/mod.rs index eb3300e6310a..ae0f60ca7261 100644 --- a/ee/tabby-webserver/src/service/mod.rs +++ b/ee/tabby-webserver/src/service/mod.rs @@ -230,7 +230,7 @@ impl WorkerService for ServerContext { if let Some(user) = user { // Apply rate limiting when `user` is not none. - if !self.user_rate_limiter.is_allowed(&user).await { + if !self.user_rate_limiter.is_allowed(request.uri(), &user).await { return axum::response::Response::builder() .status(StatusCode::TOO_MANY_REQUESTS) .body(Body::empty())