mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
dropping console on production
This commit is contained in:
@@ -93,7 +93,7 @@ if (frontendBuildPath) {
|
||||
}
|
||||
|
||||
// Root route
|
||||
app.get('/', (req, res) => {
|
||||
app.get('/', apiLimiter, (req, res) => {
|
||||
if (!frontendBuildPath) {
|
||||
return res.status(500).send('Frontend build not found');
|
||||
}
|
||||
@@ -110,7 +110,7 @@ app.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
// Client-side routing fallback
|
||||
app.get('*', (req, res) => {
|
||||
app.get('*', apiLimiter, (req, res) => {
|
||||
// Ignoriere API Routes
|
||||
if (req.path.startsWith('/api/')) {
|
||||
return res.status(404).json({ error: 'API endpoint not found' });
|
||||
@@ -137,12 +137,34 @@ app.get('*', (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Production error handling - don't leak stack traces
|
||||
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
console.error('Error:', err);
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
res.status(500).json({
|
||||
error: 'Internal server error',
|
||||
message: 'Something went wrong'
|
||||
});
|
||||
} else {
|
||||
res.status(500).json({
|
||||
error: 'Internal server error',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Error handling middleware
|
||||
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
console.error('Unhandled error:', err);
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
});
|
||||
|
||||
app.use('*', (req, res) => {
|
||||
res.status(404).json({ error: 'Endpoint not found' });
|
||||
});
|
||||
|
||||
// Initialize the application
|
||||
const initializeApp = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user