Replies: 1 comment 2 replies
-
when i try this in nextjs, i get errors about how "Cookies can only be modified in a Server Action" even though it is in a server action. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Update the session data from the server, while preventing the client from doing the same.
Non-Goals
No response
Background
Server-side session updates are currently possible using a combination of
jwt
callbacks:next-auth/apps/dev/nextjs/auth.config.ts
Lines 48 to 51 in 5c49f95
And
unstable_update
:next-auth/apps/dev/nextjs/app/page.tsx
Line 1 in 5c49f95
next-auth/apps/dev/nextjs/app/page.tsx
Lines 22 to 29 in 5c49f95
It works, but it really doesn't feel right. With the current setup, the client can inject any data they want to the current session token, due to the
jwt
callback. But this setup will not work without the having that callback.Proposal
Have a server-exclusive method for updating the session data.
The
jwt
callback method above should be optional for users who really want to have a client-side method for updating the session.I'm hoping that the current state is temporary (they are marked as
unstable_*
after all) and that they will be improved in the future.Beta Was this translation helpful? Give feedback.
All reactions