The error message you're seeing is indicating that you're trying to modify cookies outside of a Server Action or Route Handler. This is not allowed in Next.js.
The cookies().set() function can only be used within a Server Action or Route Handler. This means you cannot use it directly inside a React component (like Page in your case).
If you want to set a cookie, you should do it in a Server Action or Route Handler. Here's an example of how you can do it in a Server Action:
import { cookies } from 'next/headers'
export async function setCookies(cookieA: string) {
'use server'
cookies().set('cookieA', cookieA)
}
Then, you can call this Server Action from your page:
import { setCookies } from '../actions'
export default function Page() {
setCookies('your-cookie-value')
}
Remember, the setCookies function in this case is a Server Action, and it should be called in a server context, not directly in a React component.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: