Next.js Discord

Discord Forum

Why I need to realod the page in order to be redirected using cookies?

Answered
Giant panda posted this in #help-forum
Open in Discord
Giant pandaOP
I've created an auth system and when i log in I get a cookie and I'm redireted to the home page, but when i go to the login page again (already logged), I'm not being redirected to the Logout page, I need to mannually refresh the page. Anyone knows what's the issue?
Answered by fuma
The page might be cached by the client, you can run router.refresh to clear the existing cache
View full answer

3 Replies

The page might be cached by the client, you can run router.refresh to clear the existing cache
Answer
Also for auth logic, we highly recommend putting it in your middleware instead for a better performance and load speed
Giant pandaOP
ok, thanks, it was very helpful