Disable WP REST API requests for logged out users

By filtering the rest_authentication_errors filter, you can return a 401 error if the request isn’t authenticated.