Skip to content
Source
Sign inSign up
TanStack/router

Redirect with basepath duplicates base in URL causing notFoundError #5324

Send to my agent
Closedkrishna-santosh(GitHub profile, opens in a new tab) opened this issue 1 comment

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

  1. Open the given reproduction link
  2. Set the router base path to /app.
  3. Navigate to /app/private.
  4. 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

  1. 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.

Sign in to join this conversation.