• Resolved plaidpowered

    (@plaidpowered)


    I ran into what’s probably an uncommon situation that caused Media Cleaner to fail to function. Essentially it wouldn’t register the REST API endpoints because it couldn’t detect that my website was running a REST request. There are two unique aspects of my site that may be at fault:
    * It’s WP site_url is a subfolder
    * The website itself is actually a subdomain but using a reverse proxy to appear as a subfolder (this may not be relevant)

    Throwing a bunch of Query Monitor logs at the problem, I finally determined the issue is because of these lines 116-117 in common/helpers.php – with my setup, the values of the variables are

    $rest_url = /subfolder/wp-json
    $current_url = /wp-json

    Which then causes the if condition on line 123-124 to fail.

    Since I only needed to use Media Cleaner once, I was able to work around the problem by throwing this in an mu-plugins file:

    if ( ! defined( 'REST_REQUEST' ) && strpos( $_SERVER['REQUEST_URI'], 'wp-json' ) !== false ) {
        define( 'REST_REQUEST', true );
    }

    And that got the job done. I can’t suggest a practical solution to fix the plugin permanently, and maybe my installation is too much of an edge case to worry about, but I thought you might want to be aware one more potential reason for the REST API failure.

    Many thanks for a great plugin
    ありがとうございます

Viewing 1 replies (of 1 total)
  • Plugin Support Val Meow

    (@valwa)

    Hey @plaidpowered ! ??

    Thank you for reporting! Indeed, this seems like a very unusual scenario that could cause such an issue. I will document your experience, and if another user encounters the same issue, this could serve as a temporary solution. If similar reports arise in the meantime, we will ensure to address this scenario directly in the plugin to enhance its usability. ??

Viewing 1 replies (of 1 total)
  • The topic ‘REST API fails to load when site is on a subfolder’ is closed to new replies.