Description
Describe the bug
I have a project using adapter-static
. I've set up the following in my src/+layout.server.js
file:
export const prerender = true;
export const trailingSlash = "always";
(Unfortunately the hosting setup I'm using requires trailingSlash
set to "always"
)
If I have a route src/foo/+page.svelte
that isn't able to be server side rendered, creating a src/foo/+page.js
file and filling it with:
export const ssr = false;
will work fine in dev. But in prod (or using Vite's preview mode) the page 404s. The network inspector says it's failing to fetch something at:
/foo/__data.json?x-sveltekit-trailing-slash=1&x-sveltekit-invalidated=10
This file doesn't exist in the build output, but for some reason the site is asking for it.
To my surprise, this also works for the route page, if it also disables SSR.
Removing the trailingSlash = "always"
or the ssr = false
options makes the site work again.
Reproduction
Create a blank SvelteKit Project using adapter-static
as it's output.
Create a src/+layout.server.js
file:
export const prerender = true;
export const trailingSlash = "always";
Create a src/+page.js
file:
export const ssr = false;
Run npm run dev
. Observe that the page works fine in dev.
Run npm run build
and npm run preview
. Observe that the page shows a 404 error.
I have created a StackBliz project showing the effect
Logs
No response
System Info
System:
OS: Windows 11 10.0.26100
CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
Memory: 16.80 GB / 31.91 GB
Binaries:
Node: 22.5.1 - C:\Program Files\nodejs\node.EXE
npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.15.5 - ~\AppData\Local\pnpm\pnpm.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.15.1 => 2.15.1
@sveltejs/vite-plugin-svelte: ^4.0.0 => 4.0.4
svelte: ^5.16.0 => 5.16.0
vite: ^5.0.0 => 5.4.11
Severity
serious, but I can work around it
Additional Information
No response