Skip to content

Commit a4c3e6e

Browse files
committed
permit successive requests to specific api endpoints
1 parent d18a488 commit a4c3e6e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

config/initializers/rack_attack.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ class Rack::Attack
4949
# Throttle all requests by IP (60rpm)
5050
#
5151
# Key: "rack::attack:#{Time.now.to_i/:period}:req/ip:#{req.ip}"
52+
EXEMPT_PATHS = ['/assets', '/api/v1/points', '/api/v1/cases'].freeze
53+
5254
throttle('req/ip', limit: 50, period: 1.minute) do |req|
53-
req.ip # unless req.path.start_with?('/assets')
55+
req.ip unless EXEMPT_PATHS.any? { |path| req.path.start_with?(path) }
5456
end
5557

5658
# Throttle POST requests to */services by IP address

0 commit comments

Comments
 (0)