- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Closed
Description
Hi @rwieruch !
I was reading your blog post and wondering when this code will be executed ?
I thought that it was forbidden to update the cookies during the rendering phase.
This code can raise the famous 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
next-authentication/src/features/auth/queries/get-auth.ts
Lines 22 to 41 in 8346197
| try { | |
| if (result.session && result.session.fresh) { | |
| const sessionCookie = lucia.createSessionCookie( | |
| result.session.id | |
| ); | |
| cookies().set( | |
| sessionCookie.name, | |
| sessionCookie.value, | |
| sessionCookie.attributes | |
| ); | |
| } | |
| if (!result.session) { | |
| const sessionCookie = lucia.createBlankSessionCookie(); | |
| cookies().set( | |
| sessionCookie.name, | |
| sessionCookie.value, | |
| sessionCookie.attributes | |
| ); | |
| } | |
| } catch {} | 
thank you for all your articles, they are great resources 🫶
Metadata
Metadata
Assignees
Labels
No labels