REST API routes return 401 errors

To leave a review, I fill out the form and press the submit button, nothing happens.

To submit a list, I fill out the form and press the button, nothing happens.

I fill out the form to leave a comment, press the button and nothing happens.

I am working on a different theme. I designed everything very well, but there is a problem with the forms. I installed WP Mail SMTP and tested it. There is no problem with SMTP setup either. I also transferred the file I was working on to the server. Likewise, the buttons do not work on the server. No function.

I would appreciate your help.

If the form buttons don’t react there’s probably a JS errors that blocks them, please share a link to your site and I’ll check this issue.

Hello, thank you for your return. But I am currently working locally. And I didn’t use the sample demos. So I am working on custom theme. Could the problem be caused by this?

/wp-json/hivepress/v1/reviews/:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
/wp-json/hivepress/v1/reviews/:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
/wp-json/hivepress/v1/reviews/:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
/wp-json/hivepress/v1/reviews/:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
/wp-json/hivepress/v1/reviews/:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)

Hello again,

Here are the errors in the console. And I removed all unnecessary js.

When you go to the extension, the following warning appears.

{“code”:“rest_no_route”,“message”:“No route was found matching the URL and request method.”,“data”:{“status”:404}}

Please try refreshing permalinks in Settings/Permalinks section, for some reason the API endpoints (where the form requests are sent) return 404 (“not found”) errors. Also please make sure that your WP installation is set up correctly and it allows overriding URLs. I recommend using Local for local WP development https://localwp.com/

I transferred my local work to the server. I fixed the w3c errors. I already made the permalinks. But the problem is still the same. There is also a problem with forms. Buttons are useless.

Now the server gave an error like this:

jquery.min.js?ver=1:4 POST /wp-json/hivepress/v1/reviews/401
send @ jquery.min.js?ver=1:4
ajax @ jquery.min.js?ver=1:4
(anonymous) @ common.min.js?ver=1.6.10:1
dispatch @ jquery.min.js?ver=1:3
r.handle @ jquery.min.js?ver=1:3
jquery.min.js?ver=1:4 POST /wp-json/hivepress/v1/reviews/401

Every time I refresh the page, different errors appear.

Failed to load resource: the server responded with a status of 401 ()
/wp-json/hivepress/v1/reviews/:1

Hello,

The source of the problem is from the jquery.min.js file.

I am using v1.12.4. If you could help with this situation, I would greatly appreciate it.

I solved the problem by adding 1.9.0 Jquery.min.js.

The forms are working. But it doesn’t show up in the comments. Where are these forms going? Where are the reviews going?

Please make sure that the WordPress installation is set up correctly and there are no server-specific settings that may cause this issue - we use the native WP API for registering REST routes register_rest_route() | Function | WordPress Developer Resources so it should be ok by default, forms seems to be ok on all the theme demos and there are no similar bug reports.
If you submitted a review it’s probably sent for moderation, please check it in WordPress/Comments section. You can disable moderation in HivePress/Settings/Reviews section.

Hello,

I already did what you said. I disabled all unnecessary plugins. I deleted the SQL and reinstalled it. I installed wp from scratch and tried again. The result is the same, you have developed the plugin according to your own themes. There is jquery error in forms. I tested all versions of jquery.min.js. Yin submits the same form. But it doesn’t go to the wp admin panel.

I did everything you said in the settings, I tried and tested it. Same result-

There is only one problem with the console…

jquery.min.js

Thanks for the details.

We use the same jQuery as any other plugin, we load it this way:

wp_enqueue_script('jquery')

And the rest is done by WordPress, we don’t load any jQuery versions specific to our plugin. If the browser console shows the jquery.min.js file name this doesn’t mean that the problem is related to jQuery, it just shows which file logs the error. If you mean previously reported issues where AJAX requests returned 401 error this means that request URLs are not accessible, but the browser console will still show the jquery.min.js file name next to the error message because this is the file that returns the AJAX request response (401 error).

I tried switching to Astra and other themes locally, and forms seem to work, please let me know if I should test some specific themes to reproduce this issue. It can be also caused by specific plugins, e.g. some security plugins may block custom AJAX endpoints by default.

If you sent the WP details via email I’ll try to debug this further, if there’s a bug and it’s not caused by a third-party script conflict or customizations we’ll fix it in any case.

Hello sir,

Thank you for your reply. I have sent detailed information to your e-mail.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.