Next.js Discord

Discord Forum

Nextjs refused to read cookies on server component in production build

Answered
Ragdoll posted this in #help-forum
Open in Discord
RagdollOP
Reading cookies (inside server component) in local environment works just fine, but attempting to read it in production build will yield error

1st image: error in production
2nd: sub-root of the app, getClaim is function call
3rd: getClaim implementation, containing cookies() call
Answered by Ragdoll
Wait, so reading is ok but modifying it is not?
View full answer

8 Replies

Asian paper wasp
The error complains you are updating the cookie, not reading it. Do you have such operations somewhere else?
RagdollOP
Wait, so reading is ok but modifying it is not?
Answer
@Ragdoll Wait, so reading is ok but modifying it is not?
Somali
In the docs it says
you can't just get cookies in the server and you end up getting them dynamically later
It also says
Which is basically what you have to do to set cookies