Using the following NextAuthConfig (with some areas redacted), I cannot get callbacks.authorized to fire. It is mentioned in the official docs https://authjs.dev/reference/next-auth#authorized with some kind of dependency on middleware, though that does not seem clear to me. Any ideas?
const authOptions: NextAuthConfig = {
trustHost: true,
session: {
strategy: 'jwt',
},
providers: [
CredentialsProvider({
id: 'mycompany',
name: 'mycompany',
type: 'credentials',
authorize: authorize as any,
credentials: {
email: { label: 'Email', type: 'text', placeholder: '[email protected]' },
password: { label: 'Password', type: 'password' },
},
}) as any,
],
pages: {
signIn: '/auth/signin',
},
callbacks: {
async authorized({ auth, request: { nextUrl } }) {
throw new Error('this never happens')
},
redirect: ({ baseUrl, url }: any) => {
// snip (works)
},
async jwt({ token, ...params }: any) {
// snip (works)
},
async session({ session, ...params }: any) {
// snip (works)
},
}
}
export default authOptions
async function authorize(credentials?: { email?: string; password?: string }) {
// snip (works)
}
npm versions:
"next": "14.2.3",
"next-auth": "5.0.0-beta.17",