How to Fix Rest API Unexpected Result in Wordpress?

Hello Friends,

How to Fix Rest API Unexpected Result in Wordpress?

I Got the error in Wordpress > Site health

The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.

The REST API call gave the following unexpected result: (403) {"code":"rest_cookie_invalid_nonce","message":"Cookie nonce is invalid","data":{"status":403}}.

I also found Error in Redirection plugin.

I Am using Breeze Plugin for Cache and Cloudways MAnaged DO server

Setting of Breeze

.Htaaccess rules -

Other Errors -

Wordpress admin bar is also not loading on front-end

Mentions -

@GulshanKumar
@itsbhanusharma
@DUGGU
@razor
@AbhishekVerma

1 Like

Do you manage or serve your WordPress site using any application? If no, you can safely ignore that.

2 Likes

Yes, i am using Wordpress application on my DO server.

I can’t ignore this for the reason that i am using redirection plugin and redirection plugin uses rest API

1 Like

have u installed any optimization plugin?

these plugin can turn off Rest API.

so try disabling plugins one by one.

2 Likes

Ok, i will try it!!

1 Like

Problem Solved!!

Here is the Fix:

Clear You Website cache then Goto Cloudways > Varnish Setting > Add new Rule

Exclude: /wp-json/ and /index.php/

Rest API Problem will be fixed.

@GulshanKumar Hi hope this would be helpful for other community members.

You Forum is great, keep doing this great work.

Thank You for replying my every thread!!

2 Likes

Thanks for sharing.

1 Like

I need to confirm one thing.

By chance, are you using Cloudflare Cache Everything page rule for your domain?

If yes, this is suppose to happen under Free and Pro plan because Page cache cannot be excluded for WordPress logged in cookies.

If you are not using Cloudflare cache everything page rule, then you can also try adding these exclude cache rule for Varnish to see if it helps.

wp-.*|wordpress.*|comment_.*|woocommerce_.*

excluding-cookies

Related topic