Next.js Discord

Discord Forum

Failed to save cookies - Implementing database strategy in Next-Auth

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
I'm trying to implement database strategy on next-auth credentials provider. I know next-auth doesn't provide this capability but I've seen online people have done it quite easily (https://nneko.branche.online/next-auth-credentials-provider-with-the-database-session-strategy/) . I configured the database to save the session and modified the [...nextauth].ts file to implement the database strategy. The problem I have now is that it doesn't save the cookie in the browser. My [...nextauth].ts file is https://pastes.dev/daxrJsSoYg.
However, I see (in the browser) the request to set it up and attach it to you below.

URL Di Richiesta: http://localhost:3000/api/auth/session Metodo Di Richiesta: GET Codice Di Stato: 304 Not Modified Indirizzo Remoto: [::1]:3000 Criterio Relativo Al Referrer: strict-origin-when-cross-origin Connection: keep-alive Content-Security-Policy: frame-ancestors 'self' Content-Type: application/json Date: Fri, 16 Jun 2023 20:32:48 GMT Etag: "bwc9mymkdm2" Keep-Alive: timeout=5 Set-Cookie: next-auth.session-token=; Max-Age=0; Path=/; HttpOnly; SameSite=Lax Vary: Accept-Encoding Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6 Connection: keep-alive Content-Type: application/json Cookie: next-auth.callback-url=http%3A%2F%2Flocalhost%3A3000%2F; next-auth.csrf-token=5a2127c7c6b11e36fe9608f3e8924c2869a7f3ebf01026f0f%7C73834128050e87c6e735013b6790dfd85580611084a77; next-auth.session-token=deea6d8-6873-48b4-84e2-63fcc60a19 Dnt: 1 Host: localhost:3000 If-None-Match: "bwc9mymkdm2" Referer: http://localhost:3000/login Sec-Ch-Ua: "Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114" Sec-Ch-Ua-Mobile: ?0 Sec-Ch-Ua-Platform: "Windows" Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: same-origin User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

0 Replies