#Why Cookies from Route not setting?

1 messages · Page 1 of 1 (latest)

gleaming sandal
#

I have read the cookies can be only modified in server actions or route files.

I have created createSession function with flag 'use server' and i am calling this function in a route.ts file with cookies function provided by nextjs but its not setting the cookie.

here is the simple code https://github.com/ShourovRoy/nextjs-cookies.git

I am using nextjs 15

GitHub

Contribute to ShourovRoy/nextjs-cookies development by creating an account on GitHub.

tropic craneBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

marble pendant
gleaming sandal
marble pendant
gleaming sandal
#

I am trying to update the tokens use refresh tokens.

I can set cookie through login server actions, read them but they are not modifying

marble pendant
#

you have to call server actions from client components. calling server actions from the server has no effect because they are no longer server actions

gleaming sandal
#

Okay. So refreshing or updating cookies while fetching data server side not possible in nextja

marble pendant
#

Yes. You cannot set cookies from server components and that is a fundamental restriction that will hold true no matter what work around you can possibly come up with

gleaming sandal
#

I have solved this problem just not after days of making a structure plan to refresh it in server side. And its working now ❤️

serene basin