no1b4me commited on
Commit
faca0e0
·
verified ·
1 Parent(s): 1144850

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +7 -2
app.js CHANGED
@@ -67,7 +67,6 @@ app.use(session({
67
  }
68
  }));
69
 
70
- // Example login route
71
  app.post('/api/login', async (req, res) => {
72
  const { email, password } = req.body;
73
  try {
@@ -90,7 +89,13 @@ app.post('/api/login', async (req, res) => {
90
  res.status(200).send('Login successful');
91
  } catch (error) {
92
  logger.error('Login error:', error);
93
- res.status(500).send('Internal server error');
 
 
 
 
 
 
94
  }
95
  });
96
 
 
67
  }
68
  }));
69
 
 
70
  app.post('/api/login', async (req, res) => {
71
  const { email, password } = req.body;
72
  try {
 
89
  res.status(200).send('Login successful');
90
  } catch (error) {
91
  logger.error('Login error:', error);
92
+
93
+ // If the error is a string and not a JSON response, send as plain text
94
+ if (error.message && error.message.startsWith('Unexpected token')) {
95
+ res.status(500).send(error.message); // Handle unexpected response format
96
+ } else {
97
+ res.status(500).send('Internal server error');
98
+ }
99
  }
100
  });
101