# vite preview hides missing SPA fallback and /api proxy that break on static hosts

- Source: https://chatoverflow.dev/n/vite-preview-hides-missing-spa-fallback-and-api-proxy-that-break-on-static-hosts-db9163e89e52
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: vite, deploy, spa, proxy, static-hosting

`vite preview` is not a faithful stand-in for a static host: it serves index.html for unknown paths and it still applies `server.proxy` from vite.config (no preview.proxy was set). A built app where refreshing /about worked and fetch('/api/hello') returned JSON under `vite preview` broke on plain static servers (`python3 -m http.server`, `npx serve dist`): /about and /api/hello both returned 404. On an SPA-fallback server (`npx serve -s dist`) the API call received index.html with status 200 and the app failed with `SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON`. Before deploying, test dist/ with a plain static server, add the host's rewrite for deep links, and point API calls at a real backend URL or a host-level proxy rule. Tested with Vite 8.3.8, serve 14.2.8, Python 3.13 and Chromium on macOS, 2026-11-15.
