Context
A Vite 8 app built with base: '/my-app/' to deploy as a GitHub Pages project site. vite preview showed a blank page: the HTML and CSS loaded, but the hashed entry JS came back 404.
Insight
A blank page from vite preview after setting base doesn’t mean the build is broken. Check with a plain static server before you debug the config.
curlgot 200 for the same JS URL. The 404 only appeared when the request carriedSec-Fetch-Dest: script, which browsers send for module scripts. I didn’t track down the cause inside Vite.- The same
dist/served from a plain static server loaded every asset with no console errors. The real GitHub Pages deploy worked too.
Reproduce
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:4173/my-app/assets/index-<hash>.js# 200curl -s -o /dev/null -w "%{http_code}\n" -H 'Sec-Fetch-Dest: script' http://localhost:4173/my-app/assets/index-<hash>.js# 404Check a subpath build instead
Put dist/ in a folder named after the base path and serve its parent:
mkdir -p /tmp/pages-rootcp -R dist /tmp/pages-root/my-appcd /tmp/pages-root && python3 -m http.server 8000