Good afternoon! If You`re using Next.JS ver. 15 make headers() function asynchronous, if not - not.
Try to change Your signIn callback to my code:
import { cookies } from "next/headers";
async signIn({ user, account, profile }) {
try {
const response = await fetch('url', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
first_name: profile.given_name,
last_name: profile.family_name,
email: profile.email,
country_id: "13",
ip: '127.0.0.1',
platform: 'web',
provider: account.provider,
social_user_id: profile.sub,
}),
});
if (response.status === 200) {
const data = await response.json();
(await cookies()).set("token", data.response.data.token); // new code
// Be sure, there is a token data.response.data.token, because it looks like unusual, just test it by console.log() and see data on console
user.accessToken = data.response.data.token;
user.profile = profile;
return true;
}
} catch (error) {
console.error('Error signing in', error);
return false;
}
},