/
grigorin
/
InterviewHelper
Обзор
Документация
Войти
/
grigorin
/
InterviewHelper
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server.js
23 строки
658 B
Grigory Nevarov
серв
02 дек 2025, 21:43
02 дек 2025, 21:43
3440751
Код
Авторство
О чём код?
import express from 'express'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { readFileSync } from 'fs'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const app = express(); const PORT = process.env.PORT || 3000; // Статические файлы app.use(express.static(join(__dirname, 'dist'))); // Все маршруты ведут на index.html (для SPA) app.get('*', (req, res) => { const html = readFileSync(join(__dirname, 'dist', 'index.html'), 'utf-8'); res.send(html); }); app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); });