Next.js Discord

Discord Forum

Error: Cookies can only be modified in a server action WHILE IN A SERVER ACTION

Unanswered
Forest bachac posted this in #help-forum
Open in Discord
Forest bachacOP
export async function clearSessionCookie() {
  12 |   "use server";
> 13 |   cookies().set(authCookieName, "");
     |             ^
  14 | }


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

1 Reply

where are you calling the action from?
@Forest bachac