I was watching an authentication tutorial by Web Dev Simplified here. While handling logout requests, the tutorial suggested that we override POST request to DELETE, but did not specify clearly why is it done so. What the tutorial showed was:
const methodOverride = require('method-override');
app.use(methodOverride('_method'));
app.delete('/logout', (req, res) => {
req.logOut(), res.redirect('/login');
});
It also had to modify the logout form to override the POST request like this:
<form action="/logout?_method=DELETE" method="POST">
Instead of using all those middlewares and overriding, I could have simply done -
app.post('/logout', (req, res) => {
req.logOut(), res.redirect('/login');
});
And it works without any noticeable problems to my untrained eye. I would like to know if there are any security issues/coding conventions that suggests to override POST to DELETE for logging out.