• Resolved pszemo

    (@pszemo)


    Hello,
    I’ve created some own routes and with Redirection plugin everything is redirected from POST/DELETE to GET.
    Using Basic Auth and some own solutions (routes/endpoints…)
    With Redirection OFF below code works fine, when Redirection Plugin is working all incoming API calls are redirected to GET

    Existed redirections just redirects:
    /name/ to /something-name/

    add_action(‘rest_api_init’, function () {
    register_rest_route(‘wp/v2’, ‘notice’, array(
    ‘methods’ => ‘POST’,
    ‘callback’ => ‘addFunc’
    ));
    register_rest_route(‘wp/v2’, ‘notice/(?P<id>\d+)’, array(
    ‘methods’ => ‘POST’,
    ‘callback’ => ‘updateFunc’
    ));
    register_rest_route(‘wp/v2’, ‘notice/(?P<id>\d+)’, array(
    ‘methods’ => ‘DELETE’,
    ‘callback’ => ‘deleteFunc’
    ));
    });

    regards,
    Przemek

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John Godley

    (@johnny5)

    Redirection does not affect the REST API in anyway like this by itself. Have you created a redirect that may be doing this?

    Thread Starter pszemo

    (@pszemo)

    Hi,
    no – existed redirections – contains:
    source url: name
    query params: exact match all parameters in any order
    title:
    match: URL only
    when matched: redirect to URL with HTTP code 301
    target url /something-name/
    group: redirections

    any parameter is not replicated in API routes and Redirections.
    When turning on Redirection all incoming POST/DELETE calls are translated to GET without data

    regards,
    Przemek

    Plugin Author John Godley

    (@johnny5)

    As mentioned, the plugin does not do this by default. I don’t understand your redirect above, but you should look through your redirects and any settings (such as force https). You can also look at https://redirect.li/http/ to check if Redirection is performing the redirect.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘With redirection own WP REST API stopped work’ is closed to new replies.