Spaces:
Running
Running
File size: 1,110 Bytes
31f12a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import express from 'express';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const PORT = process.env.PORT || 7860;
const app = express();
// --- ENDPOINT SEGURO DE CONFIGURACIÓN ---
// React llamará a esta ruta para obtener las credenciales
app.get('/api/config', (req, res) => {
try {
// Leemos el SECRETO de Hugging Face
const config = process.env.FIREBASE_CONFIG;
if (!config) {
return res.status(500).json({ error: "No hay configuración en el servidor" });
}
// Lo enviamos al frontend como JSON
res.json(JSON.parse(config));
} catch (error) {
res.status(500).json({ error: "Error parseando la configuración" });
}
});
// Servir archivos estáticos
app.use(express.static(path.join(__dirname, 'dist')));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});
app.listen(PORT, '0.0.0.0', () => {
console.log(`Servidor escuchando en http://0.0.0.0:${PORT}`);
}); |