Next.js Discord

Discord Forum

router push dont work if middleware has redirected to login page nextjs 14.2.4

Unanswered
Alaska pollock posted this in #help-forum
Open in Discord
Alaska pollockOP
I have problem where i redirect to login page if auth cookies is not set.

When i login i get cookie and router.push("/") should route to frontpage but nothing happens. Also i have breadcrumps component and i when i'm redirected to login page it doest work.

what should i try?

router is freezed and even router.refresh() doesnt affect

3 Replies

Could you share your code on how you are implementing this?
Alaska pollockOP
its pretty simple. If not logged in -> redirect to login , if logged in doublecheck cookies and roles. If i take middleware off -> router.push works but if user is redirected to login router dont work
and login page is client component