salomonsky commited on
Commit
144892f
·
verified ·
1 Parent(s): cac362f

Update server.mjs

Browse files
Files changed (1) hide show
  1. server.mjs +14 -3
server.mjs CHANGED
@@ -1,6 +1,7 @@
1
  import express from 'express';
2
  import path from 'path';
3
  import { fileURLToPath } from 'url';
 
4
 
5
  const __filename = fileURLToPath(import.meta.url);
6
  const __dirname = path.dirname(__filename);
@@ -8,12 +9,22 @@ const PORT = process.env.PORT || 7860;
8
 
9
  const app = express();
10
 
11
- app.use(express.static(path.join(__dirname, 'dist')));
 
 
 
 
 
 
 
 
 
 
12
 
13
  app.get('*', (req, res) => {
14
- res.sendFile(path.join(__dirname, 'dist', 'index.html'));
15
  });
16
 
17
  app.listen(PORT, '0.0.0.0', () => {
18
- console.log(`Server running on port ${PORT}`);
19
  });
 
1
  import express from 'express';
2
  import path from 'path';
3
  import { fileURLToPath } from 'url';
4
+ import fs from 'fs'; // Importamos file system
5
 
6
  const __filename = fileURLToPath(import.meta.url);
7
  const __dirname = path.dirname(__filename);
 
9
 
10
  const app = express();
11
 
12
+ const distPath = path.join(__dirname, 'dist');
13
+
14
+ // DIAGNÓSTICO: Verificar si la carpeta existe
15
+ if (fs.existsSync(distPath)) {
16
+ console.log(`✅ Carpeta 'dist' encontrada en: ${distPath}`);
17
+ console.log('Archivos:', fs.readdirSync(distPath));
18
+ } else {
19
+ console.error(`❌ ERROR CRÍTICO: No se encuentra la carpeta 'dist'. La construcción falló.`);
20
+ }
21
+
22
+ app.use(express.static(distPath));
23
 
24
  app.get('*', (req, res) => {
25
+ res.sendFile(path.join(distPath, 'index.html'));
26
  });
27
 
28
  app.listen(PORT, '0.0.0.0', () => {
29
+ console.log(`Servidor escuchando en http://0.0.0.0:${PORT}`);
30
  });