Next.js Discord

Discord Forum

Cookies can only be modified in a Server Action or Route Handler

Unanswered
English Spot posted this in #help-forum
Open in Discord
English SpotOP
portal:dev:  ⨯ next/dist/src/server/web/spec-extension/adapters/request-cookies.ts (22:11) @ Proxy.callable
portal:dev:  ⨯ Error: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options
portal:dev:     at handleNoSession (./src/app/[lang]/(portal)/actions.ts:55:27)
portal:dev:     at async Page (./src/app/[lang]/(portal)/page.tsx:30:9)
portal:dev: digest: "3889043576"
portal:dev:   20 |
portal:dev:   21 |   public static callable() {
portal:dev: > 22 |     throw new ReadonlyRequestCookiesError()
portal:dev:      |           ^
portal:dev:   23 |   }
portal:dev:   24 | }
portal:dev:   25 |

the setting of the cookie is called from a server action. why am i getting this error? using next 15.

1 Reply

Asian black bear
Are you calling that action while rendering? If so, then the same restriction applies because you're attempting to call it from a server-side component rather than calling the action from the client.