Hello, please i need help and i am totaly lost..
I have Next.js, NestJS, and auth.js
From Next.js I call signin in auth.js to log in via Google
After login I call a callback in auth.ts
In that callback I try to call my Nest backend to save callback data (email, id, etc.)
Everything like withCredentials, res.cookies, secure, httpOnly etc. is set and cookies ARE SENT back
The problem is probably that since auth.js runs server-side, it can’t store cookies (probably), so I’m looking for a way. It doesn’t have to be direct cookie storage in that function… My goal is simply to have the cookies saved on the client.
import {google_signin} from '@/axios/routes/google/google.api';
import NextAuth from 'next-auth';
import Google from 'next-auth/providers/google';
export const {handlers, signIn, signOut, auth} = NextAuth({
providers: [Google],
callbacks: {
async signIn({user}) {
google_signin(user)
.then((res) => console.log('COOKIES', res.headers['set-cookie']))
.catch((err) => console.error(err));
return true;
},
},
});
google_signin DOES return cookies. But i cant save them..