Support » Developing with WordPress » rest_authentication_errors not invoked for GET requests to /posts using jquery

  • Resolved tfryc

    (@tfryc)


    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/posts endpoint 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?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.