Skip to content

Redirect with basepath duplicates base in URL causing notFoundError #5324

Closed

Description

@krishna-santosh

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

Activity

  1. Amko94 commented on Oct 1, 2025

    @Amko94

    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.

  2. added a commit that references this issue on Oct 1, 2025
    a2da3f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions