diff --git a/.changeset/lazy-pugs-refuse.md b/.changeset/lazy-pugs-refuse.md new file mode 100644 index 000000000000..7707628b8902 --- /dev/null +++ b/.changeset/lazy-pugs-refuse.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-netlify': patch +--- + +fix: strip trailing slashes from prerendered paths in the edge function exclude list, so the root page is served statically when using a base path diff --git a/packages/adapter-netlify/index.js b/packages/adapter-netlify/index.js index cd8ff0521324..db7d43fea1ef 100644 --- a/packages/adapter-netlify/index.js +++ b/packages/adapter-netlify/index.js @@ -138,7 +138,8 @@ async function generate_edge_functions({ builder }) { // Contains static files `/${builder.getAppPath()}/immutable/*`, `/${builder.getAppPath()}/version.json`, - ...builder.prerendered.paths, + // the base root and `trailingSlash: 'always'` pages are recorded with a trailing slash + ...builder.prerendered.paths.map((path) => (path === '/' ? path : path.replace(/\/$/, ''))), ...Array.from(assets).flatMap((asset) => { if (asset.endsWith('/index.html')) { const dir = asset.replace(/\/index\.html$/, '');