Which project does this relate to?#
Router
Describe the bug#
When using a basepath (e.g., /app), calling redirect() appends the basepath again to the URL, resulting in an incorrect URL and a notFoundError.
Ex:
It should redirect to /app/private/$privateId
But it is redirecting to /app/app/private/$privateId
Note:
Redirect works fine without the basepath
i.e
Redirecting to /private/$privateId works fine
Your Example Website or App#
https://stackblitz.com/edit/github-sagxavol?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue#
- Open the given reproduction link
- Set the router base path to /app.
- Navigate to /app/private.
- This route triggers a redirect to /app/private/$privateId.
Expected behavior#
The redirect should navigate to /app/private/$privateId without duplicating the base path.
but
The redirect navigates to /app/app/private/$privateId, causing a notFoundError.
Screenshots or Videos#
No response
Platform#
- Router [version 1.132.27]
Additional context#
Yes, same problem here with TanStack Router v1.132.41. Also happens with navigate(), in two identical scenarios: in one it works, in the other not. If baseUrl is default /, it works fine. With custom baseUrl like /app, sometimes it navigates correctly, sometimes it doubles the path (e.g., /app/app/../..) and throws a not found. It's sporadic—I can't nail down why exactly. Without custom basepath, all good.