My Next js application is not using the response cookies on production. It works like a charm in development and in local build. The cookies are in the response in all cases, but in production they are not saved on client broswer.
The response:
I found the problem. It works on localhost just because the backend is also running on localhost. When I tried to use the production backend it produces the same bad results. The point is that the cookies are by default not shared across different domains. So I needed to set SameSite as None in the backend in order to use it in a separate domain. Hope it helps the next person that encounters this problem. In my case, the backend is made in Django, so this site was very helpful: https://yoongkang.com/blog/cookie-based-authentication-spa-django/