TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.19k stars 486 forks source link

Redirect not showing correct components but will append the correct URL #1541

Closed jexodusmercado closed 2 weeks ago

jexodusmercado commented 2 weeks ago

Describe the bug

I am using the version 1.31.3 in my repository. Redirect is not working properly if I enter the URL directly inside instead of navigating thru UI. Sample authentication repo also has this bug.

Your Example Website or App

https://codesandbox.io/p/devbox/github/tanstack/router/tree/main/examples/react/authenticated-routes?embed=1&file=%2Fsrc%2Froutes%2F_auth.tsx%3A22%2C5&theme=light

Steps to Reproduce the Bug or Issue

  1. enter the /invoice url
  2. no error but will show the invoice components instead of the login

Expected behavior

As a user, I should be redirected to the correct screen. In this case, I am able to view the protected routes even if I am not yet authenticated.

Screenshots or Videos

No response

Platform

Additional context

No response

SeanCassiere commented 2 weeks ago

Same as #1537.

jexodusmercado commented 2 weeks ago

I think this is also the same with #1528. Downgraded to 1.28.1 to make it work for now.

tmkn commented 2 weeks ago

Seems like an unfortunate time to checkout the project. I set it up yesterday, file base routing. I have an / index route and a /login route and made it so that the index route always redirects to the login route via beforeLoad and throw redirect(...), just to try things and it just wouldn't work.

upon accessing the / route, the url shows /login but the displayed component is the one from the index route :( Upon reloading (browser url shows /login) it only then shows the component for the /login route.

tannerlinsley commented 2 weeks ago

@tmkn Unfortunate indeed as I'm currently fixing this issue!

tmkn commented 2 weeks ago

@tannerlinsley all good, I saw you were working on it, updating to 1.31.4 fixed some of the issues like redirecting from /foo to /login.

I like the type safety of the routes and its not urgent to have it working, will most likely stick with it anyway once it's working, I like what I've seen so far :)

SeanCassiere commented 2 weeks ago

Tanner has fixed this and it's available in 1.31.5 release.