cookies in nextj 14
Unanswered
Barbary Lion posted this in #help-forum
Barbary LionOP
what are the options or proper ways to handle cookies. I need to clear specific cookie and redirect to login if i get auth error from query that i make in page component. If i use server action for clearing a cookie and redirect in page.tsx using redirect() fn i doesnt work, since it doesnt wait for cookies to be cleared and redirects immidietly
5 Replies
Barbary LionOP
currently im returning a client component if i get that auth error, that handles cookie removal and redirects on client side using router
but it doesnt seem like a proper way of doing it.
I think you can call redirect in server action
@Yi Lon Ma I think you can call redirect in server action
Barbary LionOP
i get error saying that cannot make cookies mod. in page. Only server action or route handlers. When i try to reset a cookie and redirect in server action that is used in page.tsx when i get auth error