Next.js Discord

Discord Forum

If you prefetch /logout, you're gonna have a bad time

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Be me.
Brand new NextJS app, yay!
1 hour every night.
Site looks good!
Launch site today, after two weeks of work.
Log in.. works!
Admin dashboard... looks good!
Click ANYTHING - redirect to login.
Scratching my head.
Network tab shows a request to /logout... ?

Project is rendering a /logout link with prefetch true in the navbar - cookies gone.

Damn.

Fixed like this:
<Link href="/logout" prefetch={false}>Logout</Link>


This happened to me for the 2nd time in 2024. Anyway, that's the story.
Thanks, bye!

2 Replies

Irish Red and White Setter
@Masai Lion What happens now if you just hover over the Link?
prefetch false supposedly does not prefetch automatically, but it still prefetches on hover.

Hover = user gets logged out?
Masai LionOP
I tried hover, it still doesn't prefetch on hover.