79571379

Date: 2025-04-13 09:26:29
Score: 1
Natty:
Report link

In Express 4 and earlier, app.all('*') acted as a catch-all route for all requests without the need to name the wildcard. However, in Express 5, it seems that the unnamed wildcard is no longer allowed and must be named.

app.get('/', (req: Request, res: Response) => {
    res.send('Hello World!');
});

app.all('/*splat', (req: Request, res: Response) => {
    res.status(404).json({
        message: `The URL ${req.originalUrl} doesn't exist`
    });
});
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: MOHAMMAD HASHEMI