Try const handler = NextAuth(authOptions); NextAuth expects an object with providers set as an array
const handler = NextAuth(authOptions)