Next.js Discord

Discord Forum

Get Cookie return undefined

Unanswered
Atlantic mackerel posted this in #help-forum
Open in Discord
Atlantic mackerelOP
Hey guys, im trying to make auth with client-side-cookie

async function accountPost(account: Account) {

    await fetch('http://localhost:8090/authorization', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(account),
    }).then(res => {
        res.json().then(value => {
            console.log(value)
            setCookie("uuid", value.data);
        })
    })

    return true;
}

im trying this


and the data return very well

[NEXT] { data: 'bad597e0-2a8d-4357-9f2e-10e12e3289bc' }

but when I tried to get that cookie like this

        let test = getCookie("uuid");
         await signIn("google", {callbackUrl: "http://localhost:3000/" + test, redirect: true});

it return undefined. how can I setup client-side cookie? (without nextjs backend or it must be required?)

0 Replies