#39830 closed defect (bug) (wontfix)
Unable to detect REST/rest_no_route
Reported by: | szepe.viktor | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7.2 |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description
AFAIK dispatch() in WP_REST_Server replies rest_no_route
with HTTP status code 404 on its own
There is no way to detect a HTTP/404 which is elemental for my WAF
https://github.com/szepeviktor/wordpress-fail2ban/blob/master/mu-plugin/wp-fail2ban-mu-instant.php#L138-L140
Please advise.
Change History (2)
Note: See
TracTickets for help on using
tickets.
The REST API routing system is independent of
template_redirect
, since it's not part of the templating system. This is by design.rest_post_dispatch
orrest_pre_serve_request
can be used to catch errors from the API.(It's also possible for 404 errors to be generated inside controllers, not just by the routing. For example, a request to a nonexistent post ID will throw a 404.)