T
TanStack7d ago
fair-rose

Custom vite base path causes prerender to fail in SPA mode

When setting vite's base option, I get the following error:
[prerender] Prerendering pages...
[prerender] Concurrency: 8
[prerender] Crawling: /
[prerender] Prerendered 1 pages:
[prerender] - /
[sitemap] Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option.
file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:109
throw new Error(`Failed to fetch ${page.path}: ${res.statusText}`, {
^

Error: Failed to fetch /:
at file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:109:19
at async file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/queue.js:38:17 {
[cause]: Response {}
}

Node.js v24.9.0
[prerender] Prerendering pages...
[prerender] Concurrency: 8
[prerender] Crawling: /
[prerender] Prerendered 1 pages:
[prerender] - /
[sitemap] Hint: Pages found, but no sitemap host has been set. To enable sitemap generation, set the `sitemap.host` option.
file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:109
throw new Error(`Failed to fetch ${page.path}: ${res.statusText}`, {
^

Error: Failed to fetch /:
at file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:109:19
at async file:///Users/andriymassimilla/Projects/a2-ai/portkey/frontend/node_modules/@tanstack/start-plugin-core/dist/esm/queue.js:38:17 {
[cause]: Response {}
}

Node.js v24.9.0
I can build the app if I omit the base setting from the vite config, but then the _shell.html roots at / instead of the intended custom base path:
...
manifest:$R[1]={routes:$R[2]={__root__:$R[3]={preloads:$R[4]=["/assets/main-C43l1_7D.js"]
...
...
manifest:$R[1]={routes:$R[2]={__root__:$R[3]={preloads:$R[4]=["/assets/main-C43l1_7D.js"]
...
any ideas?
4 Replies
united-yellow
united-yellow7d ago
did you set router basePath as well?
fair-rose
fair-roseOP7d ago
I have tried with both this rewrite set and unset, same result
rewrite: rewriteBasepath({
basepath: <custom basepath>,
}),
rewrite: rewriteBasepath({
basepath: <custom basepath>,
}),
united-yellow
united-yellow7d ago
can you please create a github issue for this, including a complete minimal reproducer project?
fair-rose
fair-roseOP7d ago

Did you find this page helpful?