Rest-API Problem | ProjectDMC.org Deutsch

[ad_1]

Hallo,

bei mir ist die Rest-API auf angemeldete Benutzer begrenzt (functions.php)

 
add_filter( 'rest_authentication_errors', function( $result ) {
// If a previous authentication check was applied,
// pass that result along without modification.
if ( true === $result || is_wp_error( $result ) ) {
return $result; }

   // No authentication has been performed yet.
   // Return an error if user is not logged in.
   if ( ! is_user_logged_in() ) {
     return new WP_Error(
       'rest_not_logged_in',
       __( 'You are not currently logged in.' ),
       array( 'status' => 401 )
     );
   }

   // Our custom authentication check should have no effect
   // on logged-in requests
   return $result;
});

Bisher hatte ich damit auch keine Probeme, jetzt sehe ich allerdings folgenden Fehler im Log

149.232.xxx.0 – – [02/Aug/2023:17:18:47 +0200] „GET /wp-json/ HTTP/1.1“ 403 210 „-“ „WordPress/6.2.2; https://example.org“

Bei dieser IP handelt es sich um die IP des eigenen Webservers. Die Fehlermeldungen kommen erst seit kurzem, hängt „vermutlich“ mit einem Update von Plugins zusammen … da es bei der Arbeit dieser auftritt. Das prüfe ich noch …

Kann ich den obrigen Code in der functions.php erweitern um einen Aufruf der Rest-API von der festen Webserver-IP zusätzlich zu den angemeldeten Usern zu erlauben?

Mit freundlichen Grüßen – Jan

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer