server serve o PWA compilado (app/dist) com fallback SPA

main
henrique 7 hours ago
parent 9b39c1ddbc
commit 42e00ab5cf

@ -48,11 +48,23 @@ app.use(
}), }),
); );
// Static: / -> <repo>/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 // Rotas da API
app.use("/api/judge", judgeRouter); app.use("/api/judge", judgeRouter);
app.use("/api/transcribe", transcribeRouter); app.use("/api/transcribe", transcribeRouter);
app.use("/api/tts-proxy", ttsRouter); 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 // Error handler padrão
app.use( app.use(
( (

Loading…
Cancel
Save