• when I attempt to clear the log file using the blue button on the csp log admin page I get the following error:

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

    Is there a way to manually clear the logs?

    I also receive the following error when I press the “Allow SCRIPT-SRC access” button

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

    I assume it’s related but I since I am able to manually add items to the CSP options page it is not a big deal – being able to clear the logs would be nice though.

    Thanks,

    Joe

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dylan

    (@dyland)

    Go to https://www.yoursite.com/wp-json and make sure it comes back with text (not an error or redirect to home page). Should start with “{“name”:”Your Site Name”,”description”” If it comes back with nothing then your rest API is disabled, maybe a security plugin did it?

    Look for wpcsp in the text (Ctrl-F in most browsers) – that’s the plugin registering the REST routes. If nothing then CSP is not registering routes – make sure its activated. Look for errors in the server error log.

    Look for RestAdmin in the text something like \/wp-json\/wpcsp\/v1\/route\/RestAdmin should appear. Make sure you’re logged in doing this as that route only registers when logged in. If nothing then CSP is not registering the admin route – make sure you’re logged in.

    If your site is in a subfolder that might cause some issues, let me know as I thought I had all of them squashed.

    Dylan

    Thread Starter joemendoza

    (@joemendoza)

    Thank you for the quick reply!

    I checked my sites json and it comes back with text (no error).

    I am able to locate “wpcsp” in the text.

    I am able to locate items that are similar to: “\/wp-json\/wpcsp\/v1\/route\/RestAdmin” in the text also.

    My site is not in a subdomain it is a top-level domain name. I created a dev site on my web host and the plugin is working fine on the dev site. I assume there must be a conflict with existing plugin/theme on my production site. I will continue to troubleshoot on my end.

    Thanks again for the quick reply.

    Plugin Author Dylan

    (@dyland)

    On the network tab of your browser what is the URL that is being requested? It should be something like https://localhost.com/wp-json/wpcsp/v1/route/RestAdmin

    There should be form data similar to:

    subaction:clearLogFile
    _wpnonce:892fafd975

    And it should be a POST (not a GET). I was testing and using GET will cause the “no rest route” error as the route is only registered for POSTs. You can manually change the register_route code to allow either – search for WP_REST_Server::CREATABLE and change it to:
    'methods' => array( WP_REST_Server::CREATABLE, WP_REST_Server::READABLE ) ,

    Making this change allows GET to work. https://localhost.com/wp-json/wpcsp/v1/route/RestAdmin?_wpnonce=zzzz

    I’ll change the underlying code to allow either method.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Manually clear log files’ is closed to new replies.