admin管理员组文章数量:1425161
Wordpress REST API "rest_authentication_errors" doesn't work external queries?
I was using following experimental codes for experimental purposes.
add_filter('rest_authentication_errors', 'auth');
function auth() { return true; }
add_action( 'rest_api_init', 'cors', 15 );
function cors() {
add_filter( 'rest_pre_serve_request', function( $value )
{
header( 'Access-Control-Allow-Origin: *' );
return $value;
});
}
Then I realized that if we made a request between two separate servers, the API's response failed. However, we have set all requests to be "correct" with the "rest_authentication_errors" filter and have accepted all connections from "*".
- If we send a "POST" request from "a" to "b", it says "authorization failed".
- But if we make a request from "a" to "a", the query works.
本文标签: Wordpress REST API quotrestauthenticationerrorsquot doesn39t work external queries
版权声明:本文标题:Wordpress REST API "rest_authentication_errors" doesn't work external queries? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745440449a2658423.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论