diff --git a/server/src/index.ts b/server/src/index.ts index 3e84e60..7aaeed1 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -48,11 +48,23 @@ app.use( }), ); +// Static: / -> /app/dist (PWA compilado; fallback SPA para rotas do front) +const APP_DIST = path.join(REPO_ROOT, "app", "dist"); +app.use(express.static(APP_DIST, { index: "index.html" })); + // Rotas da API app.use("/api/judge", judgeRouter); app.use("/api/transcribe", transcribeRouter); app.use("/api/tts-proxy", ttsRouter); +// Fallback SPA: qualquer GET que nao seja /api/* serve o index.html do app +app.get(/^\/(?!api\/).*/, (req, res, next) => { + if (req.method !== "GET") return next(); + res.sendFile(path.join(APP_DIST, "index.html"), (err) => { + if (err) next(); + }); +}); + // Error handler padrĂ£o app.use( (