[start] Incomplete basepath handling
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
[!NOTE]
The solution was to also set thebaseproperty in the vite config. I'll leave the issue open until this is documented.
Which project does this relate to?
Start
Describe the bug
When setting a basepath, every single resource needs to be prefixed with that basepath, or the app will break when put behind a proxy that only routes requests to that basepath to the app.
We have a very prod-like setup for local dev, so we need basepath handling to work fully for the dev server, or it breaks, since we only route requests to /app over to our dashboard application.
Here are my findings of things that break so far when setting basepath to /app:
- Without creating a client entry point,
/~start/default-client-entryis requested - If I create a client entry point, all the imports from client.tsx are requested without the basepath.
/@vite/client/node_modules/.vite/deps/solid-js_web.js?v=e4a53580/@fs/Users/jakst/project/node_modules/.pnpm/@tanstack+solid-start@1.130.15_solid-js@1.9.7_vite-plugin-solid@2.11.8_solid-js@1.9.7_v_2de64603fd083e50c9f52c16fb1b9292/node_modules/@tanstack/solid-start/dist/esm/client.js?v=e4a53580/src/router.tsx
Another thing that is a bit weird with basepath handling is that if I create routes/api.hello.tsx as a serverFileRoute, it does not get the basepath applied. So all serverFileRoutes have to be put in a folder with the basepath name, while the regular page routes have the basepath applied automatically.
Your Example Website or App
https://codesandbox.io/p/devbox/jovial-dawn-63xwyj
Steps to Reproduce the Bug or Issue
I couldn't get the codesandbox working, but it's fairly straight forward:
- Create a new tanstack start project
- Add
basepath: '/app'to the options inrouter.tsx - Open the app in your browser and notice that
/~start/default-client-entryis requested without the basepath - Add a default client entry point
- Restart the dev server
- Go to the app in your browser again
- Notice that the browser requests a bunch of files that are not prefixed with
/app
Expected behavior
I expect all files requested from the dev server to be prefixed with /app.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.130.15
- OS: MacOS
- Browser: Chrome
- Browser Version: 138
- Bundler: vite
- Bundler Version: 7.0.6
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue concerns TanStack Start basepath handling and notes that setting the Vite base property is the solution. Start by locating the Start and Vite configuration documentation for basepaths and proxied deployments. Document the required setting and expected /app-prefixed resource requests; done when the documented setup covers the reported development-server behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100