Wordpress Simple-JWT-Login plugin is giving 405 method not allowed for DELETE and PUT call

81 Views Asked by At

I have developed and deployed react-wp-theme app in wp-engine. I have used simple-jwt-login plugin for user management. Register, Login, sending reset email api calls are working without any issues since those are POST calls.

But when I am trying to delete the user or reset the password using the code I got from email is not working. Bothe DELETE and PUT calls giving 405 error.

simple jwt plugin configurations for DELETE enter image description here

enter image description here

.htacces file

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

ReactJS code API Call

const deleteHandler = async (e) => {
    e.preventDefault();
    setLoading(true);
    const token = localStorage.getItem("access_token");
    axiosInstance
      .delete(
        apiHost +
          `/?rest_route=/simple-jwt-login/v1/users&JWT=${token}&AUTH_KEY=${API}`
      )
      .then((res) => {
        console.log(res);
        localStorage.removeItem("access_token");
        localStorage.removeItem("userInfo");
        setLoading(false);
        navigate("/");
      })
      .catch((err) => {
        console.log(err);
        setLoading(false);
      });
  };

**Error log on delete method fails from wp-engine ** enter image description here

0

There are 0 best solutions below