From 2f342b74a5b2c369bc616c66a92166c31feb4a36 Mon Sep 17 00:00:00 2001 From: FAQ Bot Date: Wed, 16 Sep 2026 04:13:18 +0000 Subject: [PATCH] NEW: FastAPI container serving fails because my AI-generated Vite frontend is --- ...astapi-ssr-no-index-html-static-spa-fix.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 _questions/ai-dev-tools-zoomcamp/03-deployment/004_c73cdc7714_vite-fastapi-ssr-no-index-html-static-spa-fix.md diff --git a/_questions/ai-dev-tools-zoomcamp/03-deployment/004_c73cdc7714_vite-fastapi-ssr-no-index-html-static-spa-fix.md b/_questions/ai-dev-tools-zoomcamp/03-deployment/004_c73cdc7714_vite-fastapi-ssr-no-index-html-static-spa-fix.md new file mode 100644 index 00000000..271a6ea7 --- /dev/null +++ b/_questions/ai-dev-tools-zoomcamp/03-deployment/004_c73cdc7714_vite-fastapi-ssr-no-index-html-static-spa-fix.md @@ -0,0 +1,22 @@ +--- +id: c73cdc7714 +question: FastAPI container serving fails because my AI-generated Vite frontend is + SSR (no static `index.html`)—how do I fix it? +sort_order: 4 +--- + +If your AI builder scaffolds your frontend with SSR (e.g., Next.js/Remix/TanStack Start or an SSR-enabled setup), the build often won’t emit a static HTML shell like `index.html`. That breaks the course’s single-container deployment approach where FastAPI serves the frontend’s static files. + +Fix it by switching the frontend build to a static SPA export, then have FastAPI serve the produced static assets: + +1) Update the frontend framework configuration to disable SSR and enable static SPA output. + - For examples like `vite.config.ts` or `next.config.js`, change the config so the build exports static HTML/CSS/JS (no Node runtime required). + +2) Re-generate/adjust your Dockerfile to match the “static frontend + FastAPI serves it” strategy. + - Use a multi-stage build: Stage 1 builds the static frontend assets; Stage 2 builds a Python/FastAPI image and copies those static files into the location FastAPI serves from. + +3) If your builder already generated the project, fix it via a follow-up to your agent: + - Tell it explicitly: “The frontend must be a static SPA build (no SSR/Node runtime). Update the frontend configuration to export static assets and update the Dockerfile so FastAPI serves those assets from the root/public path.” + +4) Lock the decision in `AGENTS.md` so the agent doesn’t revert later: + - Add a single rule: “The frontend is a static SPA. Production builds must output static files to be served by FastAPI; do not introduce a Node.js server runtime.” \ No newline at end of file