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
When token is expired or the session is null and when the app want to automatically sign in again, the app show this error
[ Server ] Error: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options
How to reproduce
use the session and signIn function in page.tsx like this
export default function Page() {
const session = await auth()
if (!session) {
await signIn("keycloak") // Force sign in to obtain a new set of access and refresh tokens
}
}
Expected behavior
use the session and signIn function in page.tsx like this
export default function Page() {
const session = await auth()
if (!session) {
await signIn("keycloak") // Force sign in to obtain a new set of access and refresh tokens
}
}
user would be redirected to login page
The text was updated successfully, but these errors were encountered:
Michahide
added
bug
Something isn't working
triage
Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
labels
Nov 12, 2024
Michahide
changed the title
Next JS 15 Cookie Error
Next JS 15 Cookie Error with Auth JS v5
Nov 12, 2024
Hi
I had a same problem
I suppose next server component doesn't have access to cookie
In this conditional I return a client component that have access to cookie
But I really don't like this solution
Mayby next-auth developers will suggest other
Environment
Reproduction URL
https://github.com/Michahide/legendary-octo-goggles.git
Describe the issue
When token is expired or the session is null and when the app want to automatically sign in again, the app show this error
[ Server ] Error: Cookies can only be modified in a Server Action or Route Handler. Read more: https://nextjs.org/docs/app/api-reference/functions/cookies#options
How to reproduce
use the session and signIn function in page.tsx like this
export default function Page() {
const session = await auth()
if (!session) {
await signIn("keycloak") // Force sign in to obtain a new set of access and refresh tokens
}
}
Expected behavior
use the session and signIn function in page.tsx like this
export default function Page() {
const session = await auth()
if (!session) {
await signIn("keycloak") // Force sign in to obtain a new set of access and refresh tokens
}
}
user would be redirected to login page
The text was updated successfully, but these errors were encountered: