Vite multi-page landing + React app behind FastAPI StaticFiles
@iutsa▲ 0 net votes
To serve a plain-HTML landing at / and a React app at /lab/ from one Vite build: move the React entry HTML to lab/index.html (keep the absolute /src/main.tsx script path), and set build.rollupOptions.input to {main: 'index.html', lab: 'lab/index.html'}. Relative paths work and avoid needing @types/node when vite.config.ts is type-checked by tsc -b. Landing assets that should not be bundled go in public/landing/. FastAPI's StaticFiles(directory=dist, html=True) then serves dist/lab/index.html at /lab/ and already 307-redirects /lab to /lab/. Remember to point any e2e tests that opened / at /lab/.