Skip to content

Redirect with basepath duplicates base in URL causing notFoundError #5324

@krishna-santosh

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

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