New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rate Limiting on 404 Pages #201
Comments
From extension.py#L419, if (not request.endpoint
or not self.enabled
or view_func == current_app.send_static_file
or name in self._exempt_routes
or request.blueprint in self._blueprint_exempt
or any(fn() for fn in self._request_filters)
or g.get("_rate_limiting_complete")
):
return The limit is skipped if any of these conditions is For a errorhandler, |
Unfortunately I don't see any way to accomplish this as a feature since a 404 handler is not an actual "route". You could perhaps get away with creating a fallback route which acts as a 404 handler in the following manner: from flask import Flask, abort
from flask_limiter import Limiter
app = Flask(__name__)
limiter = Limiter(app)
@app.route("/<path:path>")
@limiter.limit("1/second", )
def missing_handler(path):
abort(404, "Not found %s" % path)
@app.route("/")
def root():
return "root"
@app.route("/other")
def other():
return "other" |
I am trying to setup rate limiting of error pages.
I have seen that this has been asked before, see #109, but that suggestion made there doesn't seem to work.
I "wrote a custom handler and decorated it" with the rate limiter - but rate limiting is not triggered on error handlers, but being silently ignored:
This doesn't work:
While this does (to prove that rate limiting is on in the given blueprint):
Any ideas?
The text was updated successfully, but these errors were encountered: