fix(api): improve 404 handling for unknown API routes
- Refactored the 404 response for API routes to ensure it only triggers for paths starting with '/api/', enhancing clarity in error handling. - Updated package dependencies in package.json and package-lock.json to maintain version consistency and address potential vulnerabilities.
This commit is contained in:
@@ -129,6 +129,11 @@ app.get(/^\/(?!api\/).*/, (req, res) => {
|
||||
});
|
||||
|
||||
// Fallback 404 for unknown API routes
|
||||
app.use('/api/*', (req, res) => res.status(404).send('404 Not Found'));
|
||||
app.use((req, res, next) => {
|
||||
if (req.path.startsWith('/api/')) {
|
||||
return res.status(404).send('404 Not Found');
|
||||
}
|
||||
return next();
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
||||
Reference in New Issue
Block a user