veltrixcode commited on
Commit
f4e0b33
·
verified ·
1 Parent(s): 4ae2d3b

Update server.js

Browse files
Files changed (1) hide show
  1. server.js +8 -4
server.js CHANGED
@@ -8,6 +8,7 @@ const fs = require('fs');
8
 
9
  const app = express();
10
  const port = process.env.PORT || 7860;
 
11
 
12
  // Middleware
13
  app.use(cors());
@@ -224,7 +225,7 @@ app.post('/api/payments', (req, res) => {
224
  const { cardholderId, amount, date } = req.body;
225
 
226
  if (!cardholderId || !amount || !date) {
227
- return res.status(400).json({ error: 'Msising fields' });
228
  }
229
 
230
  const insertPayment = 'INSERT INTO payments (cardholder_id, amount, payment_date) VALUES (?, ?, ?)';
@@ -306,6 +307,9 @@ app.post('/api/admin/flush', (req, res) => {
306
  });
307
  });
308
 
309
- app.listen(port, () => {
310
- console.log(`Server running at http://localhost:${port}`);
311
- });
 
 
 
 
8
 
9
  const app = express();
10
  const port = process.env.PORT || 7860;
11
+ const host = '0.0.0.0'; // Listen on all network interfaces
12
 
13
  // Middleware
14
  app.use(cors());
 
225
  const { cardholderId, amount, date } = req.body;
226
 
227
  if (!cardholderId || !amount || !date) {
228
+ return res.status(400).json({ error: 'Missing fields' });
229
  }
230
 
231
  const insertPayment = 'INSERT INTO payments (cardholder_id, amount, payment_date) VALUES (?, ?, ?)';
 
307
  });
308
  });
309
 
310
+ // Start server on 0.0.0.0 to allow external connections
311
+ app.listen(port, host, () => {
312
+ console.log(`Server running at http://${host}:${port}`);
313
+ console.log(`Accessible locally at http://localhost:${port}`);
314
+ console.log(`Accessible on network at http://<your-ip>:${port}`);
315
+ });