/
ai_sampletext
/
DiplomWork
Обзор
Документация
Войти
/
ai_sampletext
/
DiplomWork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
server/static.ts
19 строк
554 B
katerinamerzla1
Extracted stack files
02 мар 2026, 12:48
02 мар 2026, 12:48
ff76d95
Код
Авторство
О чём код?
import express, { type Express } from "express"; import fs from "fs"; import path from "path"; export function serveStatic(app: Express) { const distPath = path.resolve(__dirname, "public"); if (!fs.existsSync(distPath)) { throw new Error( `Could not find the build directory: ${distPath}, make sure to build the client first`, ); } app.use(express.static(distPath)); // fall through to index.html if the file doesn't exist app.use("/{*path}", (_req, res) => { res.sendFile(path.resolve(distPath, "index.html")); }); }