• Resolved Hayden Ng

    (@haydenng664)


    I have been getting these infinite errors from this plugin in the console:
    GET .../wp-json/wp-offload-media/v1/state/ 403
    Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'is_upgrading')

    and in the WP Offload Media Lite settings page:
    Error From Server
    Cookie check failed

    I already have the plugin and WordPress updated to the latest version.
    When I tried to visit the rest api url .../wp-json/wp-offload-media/v1/state/, it does show
    error code: rest_forbidden
    error msg: Sorry, you are not allowed to do that.
    status: 401

    What is the issue that could be causing this?

    • This topic was modified 2 years, 4 months ago by Hayden Ng.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Delicious Brains

    (@deliciousbrains)

    WP Offload Media’s settings page uses the WP-REST-API to talk to the WordPress backend, but isn’t being allowed to use REST calls.

    Does the site have WP-REST-API disabled?

    -IJ

    Thread Starter Hayden Ng

    (@haydenng664)

    Hi, thanks for the reply.

    No the site does not have the REST api disabled and the /wp-json/ can be accessed without problem. Any other sources that could be causing this issue?

    Thread Starter Hayden Ng

    (@haydenng664)

    Hi, I have managed to scope down the issue.

    Apparently, the errors only appear when I change the site url to be a different one rather than the same one as the wordpress address. Because my site is a headless site, different subdomains for frontend and backend.

    Maybe the plugin doesn’t cater for this type of scenario?

    Plugin Author Delicious Brains

    (@deliciousbrains)

    The plugin uses the standard get_rest_url() function supplied by WordPress to determine where requests should go to.

    That function does indeed look to use the home_url for the base of its URL.

    There is a rest_url filter you could likely use to override the returned URL.

    https://developer.www.ads-software.com/reference/hooks/rest_url/

    -IJ

    Thread Starter Hayden Ng

    (@haydenng664)

    Hi, thanks for the context.

    If I were to add the rest_url filter in the plugin function, wouldn’t it be overwritten when your plugin is updated to a new version.

    Plugin Author Delicious Brains

    (@deliciousbrains)

    @haydenng664 that’s right, you should never edit our plugin’s code.

    Instead you should add a filter function to your child theme’s functions.php file, or to a custom plugin of your own.

    https://developer.www.ads-software.com/plugins/hooks/filters/

    Your developer should be able to help you out with this and correctly set the URL for your headless setup.

    -IJ

    Thread Starter Hayden Ng

    (@haydenng664)

    Thanks!

    I have found the snippet that I need from wptips:

    // change WordPress API URL to HOME URL
    add_filter('rest_url', 'wptips_home_url_as_api_url');
    function wptips_home_url_as_api_url($url) {
        $url = str_replace(home_url(),site_url() , $url);
        return $url;
    }

    It is working now. Thanks!

    Plugin Author Delicious Brains

    (@deliciousbrains)

    Excellent news, thanks for sharing your solution!

    -IJ

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Get …/wp-json/wp-offload-media/v1/state/ Error 403 Rest Forbidden’ is closed to new replies.