salomonsky commited on
Commit
18c2ffb
·
verified ·
1 Parent(s): 81a3b87

Delete server.mjs

Browse files
Files changed (1) hide show
  1. server.mjs +0 -34
server.mjs DELETED
@@ -1,34 +0,0 @@
1
- import express from 'express';
2
- import path from 'path';
3
- import { fileURLToPath } from 'url';
4
- import fs from 'fs';
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
- // Puerto 7860 obligatorio para Hugging Face
9
- const PORT = process.env.PORT || 7860;
10
-
11
- const app = express();
12
- // Definimos explícitamente la ruta a la carpeta compilada
13
- const distPath = path.join(__dirname, 'dist');
14
-
15
- // --- VERIFICACIÓN DE SEGURIDAD ---
16
- if (fs.existsSync(distPath)) {
17
- console.log(`✅ Carpeta 'dist' encontrada. Sirviendo aplicación compilada.`);
18
- } else {
19
- console.error(`❌ ERROR CRÍTICO: No existe la carpeta 'dist'.`);
20
- console.error(` Esto significa que 'npm run build' falló o no se ejecutó.`);
21
- console.error(` El servidor intentará servir archivos fuente, lo cual fallará en el navegador.`);
22
- }
23
-
24
- // 1. Servir archivos estáticos SÓLO desde 'dist'
25
- app.use(express.static(distPath));
26
-
27
- // 2. Cualquier otra ruta, devuelve el index.html COMPILADO (no el de la raíz)
28
- app.get('*', (req, res) => {
29
- res.sendFile(path.join(distPath, 'index.html'));
30
- });
31
-
32
- app.listen(PORT, '0.0.0.0', () => {
33
- console.log(`🚀 Servidor escuchando en http://0.0.0.0:${PORT}`);
34
- });