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
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
-
I am trying to get session for my users. I want to use the session to redirect the user based on their role
async redirect({ url, baseUrl }) { const sessionRes = await fetch(
${baseUrl}/api/auth/session`);const session = await sessionRes.json();
console.log('--->>SSR',sessionRes)
The console is logging this and not returning the user object
--->>SSR Response { status: 200, statusText: 'OK', headers: Headers { vary: 'RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch', 'content-type': 'application/json', 'set-cookie': 'next-auth.csrf-token=d3ec5e90446a91d963a03e5542a3269ce917f03a71e11a1457ede076e96ecd81%7Cef4e1ea527ae448e4401756b741db72a61213905adfd02a888dbd80ecde5fbf5; Path=/; HttpOnly; SameSite=Lax, next-auth.callback-url=http%3A%2F%2Flocalhost%3A3000; Path=/; HttpOnly; SameSite=Lax', date: 'Mon, 17 Feb 2025 16:55:47 GMT', connection: 'keep-alive', 'keep-alive': 'timeout=5', 'transfer-encoding': 'chunked' }, body: ReadableStream { locked: true, state: 'closed', supportsBYOB: true }, bodyUsed: true, ok: true, redirected: false, type: 'default', url: 'http://localhost:3000/api/auth/session' }
but if I go to api/auth/session manually on my browser the correct user data is being returned
Beta Was this translation helpful? Give feedback.
All reactions