rest_authentication_errors not invoked for GET requests to /posts using jquery
-
I’m authorizing calls to the REST API using the using the implementation described here. It works great except for 1 unique scenario. The rest_authentication_errors hook does not get fired when calling the
/wp/v2/postsendpoint from jquery:$.ajax({ url: "https://www.sample.com/wp-json/wp/v2/posts", method: "GET" })What’s strange is that if I open the URL in a browser directly or in Postman, it does perform the authentication and returns a 401 as expected. What’s also strange is that if I make the jquery ajax call to other endpoints, like
/wp/v2/users, it also performs the authentication and returns a 401. Any ideas what is causing the ajax call to the /posts endpoint to bypass the rest_authentication_errors hook?
The topic ‘rest_authentication_errors not invoked for GET requests to /posts using jquery’ is closed to new replies.