kit
kit copied to clipboard
Missing .html file extension when prerendering on Vercel
Describe the bug
When using the static adapter and prerendering the entire site, building on my local machine generates files with the .html extension for every route. Building on Vercel, however, only index.html has the .html extension. The other routes are missing an extension.
Vercel manages to resolve requests to those files even without the extension. However, the issue is with a 404 error handling route. To deal with invalid routes on a fully prerendered site, you need to provide a 404.html file for Vercel to use as a handler. Vercel needs 404.html with that exact name, so without the extension it doesn't work.
Furthermore, if you try to rename the route folders to contain the .html extension, then Vercel doesn't build them at all.
Reproduction
- Fresh SvelteKit install with
@sveltejs/adapter-static. - Set up the following routes:
/routes/+page.svelte
/routes/test/+page.svelte
/routes/404/+page.svelte
- Create
/routes/+layout.server.tswith the contentexport const prerender = true;. - Run
build
When building on my local machine, the result is:
index.html
test.html
404.html
When building on Vercel, the result is:
index.html
test
404
The expected result is the same as the local build, so the issue is that the .html extensions are missing.
Now rename the paths to get the following project structure:
/routes/+page.svelte
/routes/test.html/+page.svelte
/routes/404.html/+page.svelte
When building locally, the result is the same as before. When building on Vercel, the result is:
index.html
The other routes are missing entirely.
Logs
System Info
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
Memory: 1.89 GB / 15.71 GB
Binaries:
Node: 20.15.1 - C:\laragon\bin\nodejs\node-v20.15.1-win-x64\node.EXE
npm: 10.7.0 - C:\laragon\bin\nodejs\node-v20.15.1-win-x64\npm.CMD
Browsers:
Edge: Chromium (131.0.2903.86)
Internet Explorer: 11.0.26100.1882
npmPackages:
@sveltejs/adapter-static: ^3.0.8 => 3.0.8
@sveltejs/kit: ^2.21.1 => 2.21.1
@sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
svelte: ^5.33.2 => 5.33.2
vite: ^6.3.5 => 6.3.5
Severity
annoyance
Additional Information
No response