Replies: 5 comments 9 replies
-
Same error: |
Beta Was this translation helpful? Give feedback.
-
You are seeing this error because you are invoking the server action directly in a server component render. You should pass the server action to action attribute of |
Beta Was this translation helpful? Give feedback.
-
I'm also facing this same issue for a similar scenario (401 from my external API). Is there any workaround for this? |
Beta Was this translation helpful? Give feedback.
-
+1 on this. It seems like it should be trivial to call |
Beta Was this translation helpful? Give feedback.
-
The issue is that server side signout cannot be called when a server component is rendering, it can only be called from a server action or a route. Another issue that I think gets a bit confusing is that, server actions can often be called during a server component render, and this too will cause the issue. So the workaround is to create a route, like "app/signout/route.ts" and if you need to call signout, just redirect the user to '/signout', and invoke the signout function from the route.
hope this helps anyone who runs into the same issue! |
Beta Was this translation helpful? Give feedback.
-
Enviromnent
I am trying to call the signOut based on API status code 401
This raised a cookies error
Error: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#cookiessetname-value-options
My understanding was that it is possible to call signOut on the server, but it seems not working.
Beta Was this translation helpful? Give feedback.
All reactions