How to handle 405?
Here is a simple way:
insert the code on https://github.com/expressjs/express/blob/master/lib/router/index.js#L253
if (method !== 'OPTIONS') req.notAllowedRoute = route
then I can handle 405 by:
const notAllowedHandler = (req, res, next) => {
if (req.notAllowedRoute) {
res.header('Allow', Object.keys(req.notAllowedRoute.methods).join(', ').toUpperCase())
res.status(405)
} else {
next()
}
}
How to handle 405?
Here is a simple way:
insert the code on https://github.com/expressjs/express/blob/master/lib/router/index.js#L253
then I can handle 405 by: