diff --git a/.changeset/prerender-trailing-slash-query.md b/.changeset/prerender-trailing-slash-query.md new file mode 100644 index 0000000000..9c7acd67a8 --- /dev/null +++ b/.changeset/prerender-trailing-slash-query.md @@ -0,0 +1,7 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +fix(start-plugin-core): keep the prerender trailing slash off the query string + +The crawler applied `withTrailingSlash` to the full path including the query string, so the slash landed inside the last search-param value and, with `crawlLinks` enabled, sent the crawl into an infinite loop. Passing ufo's `respectQueryAndFragment` flag keeps the slash on the path. diff --git a/packages/start-plugin-core/src/prerender.ts b/packages/start-plugin-core/src/prerender.ts index 2fbd9e74b9..a20d1e6928 100644 --- a/packages/start-plugin-core/src/prerender.ts +++ b/packages/start-plugin-core/src/prerender.ts @@ -137,7 +137,7 @@ export async function prerender({ try { const res = await requestWithRedirects( - withTrailingSlash(withBase(page.path, routerBasePath)), + withTrailingSlash(withBase(page.path, routerBasePath), true), { headers: { ...(prerenderOptions.headers ?? {}),