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 work with direct url #1537

Closed tkimvu closed 2 weeks ago

tkimvu commented 2 weeks ago

Describe the bug

In latest authenticated-routes example. When click to dashboard link from index, that work. But if write direct url like http://localhost:3001/dashboard => url redirect to http://localhost:3001/login?redirect=%2Fdashboard BUT auth layout loaded with isAuthenticated: false

Your Example Website or App

https://github.com/tanstack/router/tree/main/examples/react/authenticated-routes

Steps to Reproduce the Bug or Issue

Clone and open

Expected behavior

I want throw redirect to login

Screenshots or Videos

Screenshot from 2024-04-30 18-19-44

Platform

Additional context

No response

SeanCassiere commented 2 weeks ago

For better context;

The redirect thrown in the beforeLoad callback in the _auth.tsx layout route, isn't correctly being resolving the redirect when you directly visit the URL (for example to /dashboard).

SeanCassiere commented 2 weeks ago

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