It is because your API route might be wrong. In my case, it's working fine with http://localhost:1337/api/auth/local
Also, you can check that API route with the below path in your strapi administration panel
Setting -> USERS & PERMISSIONS PLUGIN -> Roles -> Select Authenticated or Public -> Permissions