79140768

Date: 2024-10-30 10:59:13
Score: 0.5
Natty:
Report link

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;
    }
},
Reasons:
  • Blacklisted phrase (1): Good afternoon
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Danil Diachenko