I have created public rest endpoint with POST method and when I try ajax or use insomnia always response with 403 forbidden nginx. Why isn't this working and how could I resolve my problem?


add_action('rest_api_init', 'registerContactPOST');

function registerContactPOST(){
    register_rest_route('fb/v1', 'contact',
            'methods' => 'POST',
            'callback' => 'contactPOST',
            'permission_callback' => '__return_true'

function contactPOST($requestData){
    return 'ok';

Client ajax:

    jQuery.ajax( {
        url: '/wp-json/fb/v1/contact',
        method: 'POST',
            'xyz' : 'xyz'
    } ).done( function ( response ) {
        console.log( response );
    } );

In xampp localhost it works fine but not with remote server.

  • Welcome to wpse! your url should be absolute, not relative Dec 22, 2021 at 11:54
  • @Buttered_Toast its not about path because test in insomnia with post method still gives 403. But ok, I will change to absolute Dec 22, 2021 at 11:56

1 Answer 1


After searching the internet looking for an answer, I contact my hosting provider. They had blocked every non-standard gateway for security purpose. Now it's resolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.