Next.js Discord

Discord Forum

I'm trying to set up a basic session login system using next-auth, but it seems the cookie header is

Unanswered
Barbado da Terceira posted this in #help-forum
Open in Discord
Barbado da TerceiraOP
I'm trying to set up a basic session login system using next-auth, but it seems the cookie header isn't working in the browser. Can someone assist me with this? Here's my code.

export const nextAuthOptions = (req: any, res) => ({ providers: [ CredentialsProvider({ name: "Credentials", credentials: { email: { label: "Email", type: "text" }, password: { label: "Password", type: "password" }, }, async authorize(credentials) { if (typeof credentials === "undefined") { return null; } const response = NextResponse.next(); try { const authUser: any = await axios.post(http://localhost:3333/auth/login`,
{
email: credentials.email,
password: credentials.password,
}
);

const cookies = authUser.headers["set-cookie"];

response.headers.set("Set-Cookie", cookies);

return response;
} catch (error) {
return null;
}
},
}),
],
});`

0 Replies