Next.js Discord

Discord Forum

Cookies dont want to remove

Unanswered
Red wood ant posted this in #help-forum
Open in Discord
Red wood antOP
Hi, I have authorization set up using accessToken and refreshToken. I fetch these tokens from the backend and store them in cookies on the frontend. Everything works fine in development, as well as in production, but there's one issue. I can't delete the cookies during logout in production – they simply stay in the application. The deployment is hosted on Azure. Has anyone encountered a similar case? Thanks and cheers.

5 Replies

How do you try to remove the cookie? @Red wood ant
Red wood antOP
i do it using "js-cookie"
Cookies.set("AccessToken", "", { expires: new Date(0) });
  Cookies.set("RefreshToken", "", { expires: new Date(0) });

 Cookies.remove("AccessToken");
   Cookies.remove("RefreshToken");
both approaches dont work
If you are using Next.js (app router) I would recommend this approach
cookies from next/headers