API 404 saveModule

#351863
  • Resolved Influentia
    Rank Math free

    Hello,
    This ticket is related to this one: https://support.rankmath.com/ticket/wp-json-rankmath-v1-savemodule-is-redirected-to-the-home-page/

    I’m facing an issue while enabling some modules on “Rank Math > Dashboard”. The problem has to do with the wp-json API: the endpoint “/wp-json/rankmath/v1/saveModule” returns a 404 with a code “rest_no_route”, however going to “/wp-json/rankmath/v1” returns that endpoint as an available endpoint.

    My stack is the following:
    – Plesk, which has a WAF, and nginx. This not blocking the request, I have tried to disallow it and it stills return 404. On the website logs it is showing the 404 GET and the nginx error: *1828 open() “/var/www/vhosts/domain.com/httpdocs/wp-json/rankmath/v1/saveModule” failed (2: No such file or directory).
    – Cloudflare, but only acts as DNS server, it’s not proxying the request, so it should not be interfering here.
    – There is no Application WAF installed (Wordfence or similar).

    I have followed the indications found in the accepted answer of the related post, which were:
    – Reset the htaccess for the WP default’s.
    – Whitelist routes in application WAF (I don’t have any).

    But still doesn’t work. Also have tried to troubleshoot the website using the plugin “Health Check & Troubleshooting” and activating only the Rank Math plugin, but the error persists, so for now I know:

    – It’s not a problem with htaccess
    – It’s not a problem with plugins incompatibility

    What can I do?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hello,

    Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.

    Can you please check with your hosting provider if there are other settings in your server that might be blocking the saveModule route?

    If that doesn’t help, please increase your PHP value to at least:

    Max input time: 150
    PHP time limit: 120

    Let us know how that goes. Looking forward to helping you.

    Hello Jeremy,

    Thank you for your reply. I have tried to change the values according to your recommendations and nothing changed. There is no problem with PHP values and time limit, because the 404 is returned a second after the request is made aprox, so it’s not a matter of a heavy operation.

    Also I don’t have any type of problem with any other plugin, it’s just a problem with Rank Math. I have talked with the hosting provider and they told me they can’t help me with this issue because the server is configured correctly (and I agree with them, it has been running for a while and it is hosting several wordpress websites without problems).

    What else can I do to fix this? It’s such a strange issue. Do you know how can I debug the problem through the code? Is there anywhere were I can see the reason of that error? I’m not a WP developer but I do have programming knowledge, so maybe I can try
    to solve it by myself if you give me some clues.

    Best regards

    Hello,

    On your website, the routes that have a different request method other than GET are getting converted to the GET method which makes them fail.

    The route you mentioned should be a POST route but when it’s called on your website it’s getting converted to a GET route.

    This could be related to a server configuration and we recommend double checking that situation.

    Don’t hesitate to get in touch if you have any other questions.

    Hello Miguel,
    First of all, thank you for your reply.
    What you are saying doesn’t make much sense to me, as if that was right, then I wouldn’t be able to log in into my website. Also, I attach you here the failing request (the saveModule one) and it is clearly saying the request was using POST method. See image here: https://gyazo.com/f6bdaa06da62df685e8a887692a5787c
    Where did you get this information from? Maybe am I not getting your message right?

    Hello,

    If you use a plugin that is able to log the API requests on your website you should see something similar to this:
    API log

    On a normal working website you should see the following:
    API log

    In the case of your website, there’s some configuration that is causing this as switching the permalinks structure to plain makes the routes work as intended.

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    Hello Miguel,
    Where are you getting this information from? Which plugin are you using on the screenshot? I’m watching my own nginx logs and they clearly say the request is done with POST HTTP method. Here you have the log: https://gyazo.com/b6b5cf25f8aaf4038edcd70047351cdb
    It is very strange that nginx logs differ from application logs, because at the end the one that processes http requests is nginx, not any wordpress plugin. However, if what you are showing is correct, then there is an application configuration in the wordpress site that is making this method change, but this also doesn’t make sense as the nginx is finally receiving the POST method independently of what it appears on the logging plugin in WordPress. The browser network tab is showing me HTTP POST method as well as provided in the previous reply.
    Also can you explain more about the permalinks issue? I don’t have configured nothing strange with WP permalinks and I don’t have broken links in my website, only some RankMath API endpoints are returning 404.

    Hello,

    We are getting these results with the REST API Log plugin which we use to check the end results of the routes on websites to make sure they are getting called correctly.

    Regarding the other situation where the plain permalinks work this is likely related to some server configuration on your website but if you would like to try a sample code to try and get around the issue you can try the following:

    
    if (!-e $request_filename){
        rewrite ^(.*)$ /index.php break;
    }
    

    Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,
    Finally I solved this issue. In my case, the solution was to proxy nginx requests to Apache, so the problem was an nginx misconfiguration.
    Thank you for your time.
    Best regards

    Hello,

    We are glad that everything has been sorted out.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

You must be logged in to reply to this ticket.