You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! im following this link: https://authjs.dev/guides/refresh-token-rotation?framework=next-js and and successfully implemented the Database strategy. After that i notice that response was taking too much, so i tried to cache the tokens with redis. it help a little bit, but them i notice multiple calls on my redis console. debbuing i notice every time, in every component thats i use the auth() or useSession() methods trigger the session callback again and its make new call for redis:
🟢 [GOOGLE_TOKENS_CACHE_HIT] { userId: '98831503-49e8-4c04-be2b-4ada6c743400' }
[ '[WATCH]', '2025-03-08T03:05:22.445Z' ]
🟢 [GOOGLE_TOKENS_CACHE_HIT] { userId: '98831503-49e8-4c04-be2b-4ada6c743400' }
[LAYOUT] 2025-03-08T03:05:24.139Z
GET /watch?v=ecXUnVbTlmg&l=PT 200 in 2383ms
GET /favicon.ico?favicon.bdd3f949.ico 200 in 96ms
🟢 [GOOGLE_TOKENS_CACHE_HIT] { userId: '98831503-49e8-4c04-be2b-4ada6c743400' }
GET /api/subscription/usage 200 in 3390ms
callbacks: {
authorized: async ({ auth }) => {
return !!auth
},
async session({ session, user }): Promise<ExtendedSession> {
// Get cached tokens
const googleTokens = await getGoogleTokens(user.id)
session.user.id = user.id
session.user.username = user.username as string
session.user.email = user.email as string
session.user.name = user.name as string
// Add tokens to session for client-side use if needed
(session as any).accessToken = googleTokens.access_token
return session
},
this is default behaviour or its a bug? i basically call ( auth() ) on layout 1x to fill the navbar with user infos. other is in simple route api to get user usage. i cant go to production this way :/
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
stack: nextjs 15 + prisma + google provider + next-auth v5
Hi! im following this link: https://authjs.dev/guides/refresh-token-rotation?framework=next-js and and successfully implemented the Database strategy. After that i notice that response was taking too much, so i tried to cache the tokens with redis. it help a little bit, but them i notice multiple calls on my redis console. debbuing i notice every time, in every component thats i use the auth() or useSession() methods trigger the session callback again and its make new call for redis:
this is default behaviour or its a bug? i basically call ( auth() ) on layout 1x to fill the navbar with user infos. other is in simple route api to get user usage. i cant go to production this way :/
thanks in advanced!
Beta Was this translation helpful? Give feedback.
All reactions