mis
mis
TTCTheo's Typesafe Cult
Created by mis on 1/29/2024 in #questions
getServerAuthSession returns null when using CredentialsProvider
i just started a new t3 app using the app router. i added just this to the providers array in the authOptions
CredentialsProvider({
name: 'username and password',
credentials: {
username: { label: 'username', type: 'text' },
password: { label: 'password', type: 'password' },
},
async authorize(credentials, req) {
return { id: '1234', name: 'John Doe', email: '[email protected]' }
},
}),
CredentialsProvider({
name: 'username and password',
credentials: {
username: { label: 'username', type: 'text' },
password: { label: 'password', type: 'password' },
},
async authorize(credentials, req) {
return { id: '1234', name: 'John Doe', email: '[email protected]' }
},
}),
thats the only change i made to the t3 generated boilerplate. if i go to /api/auth/signin, and even if i call the signIn function with 'credentials' as the first argument, it returns ok true, error null, and the next-auth.* cookies are being created. so it seems to be working fine, but getServerAuthSession inside server components still returns null always. if i login with discord instead, it works fine, and getServerAuthSession returns an object. so, any idea why? do i need to setup something else to make the credentials provider work?
4 replies