T
TanStack2y ago
eager-peach

Intended behaviour for navigation

Hi All, just curious if this is intended behaviour cause I couldn't really find it in the docs but if i have a route that is <host>/auth/logout and I create a link to it I get typescript autocompletion that first defaults to
<Link to="auth/logout">
Logout
</Link>
<Link to="auth/logout">
Logout
</Link>
but when this is clicked it will append the auth/logout to whatever url the user is currently on e.g. if the user is on <host>/foo it will navigate them to <host>/foo/auth/logout. This can be fixed by giving the path a leading forward / like this:
<Link to="/auth/logout">
Logout
</Link>
<Link to="/auth/logout">
Logout
</Link>
and this works as intended by linking the user to the intended route <host>/auth/logout. So I was wondering if this is intended and if I should open a github issue or if its a skill issue on my part (if it is im sorry for wasting your time)
6 Replies
extended-salmon
extended-salmon2y ago
can you please provide a minimal complete example? e.g. by forking one of the existing examples on stackblitz
eager-peach
eager-peachOP2y ago
Yeah, my bad should've made one from the start. https://stackblitz.com/edit/tanstack-router-qltgao?file=README.md Is the example I made and you can click the "Logout Incorrect" button and it will just append the links path to the current path. However making the example I think the behaviour is intended and im just having a skill issue so im sorry for wasting your time
extended-salmon
extended-salmon2y ago
@Chris Horobin can you please have a look at the autocompletion here?
extended-salmon
extended-salmon2y ago
without a from, autocorrect suggests the incorrect value auth/logout (NO leading slash!)
No description
extended-salmon
extended-salmon2y ago
with a valid from, autocomplete is correct
No description
vicious-gold
vicious-gold2y ago
Yeah. I've noticed this for a while. I thought it was intended. But yeah, it doesn't make sense when from is not provided It's like we are assuming from is the root. Which it is not

Did you find this page helpful?