[next-auth][error][adapter_error_getUserByAccount]; Unable to access attributes of an unspecified item (viewing 'findUnique')

Currently, I am developing a sign up page that integrates with three popular providers (Twitter, Facebook, and Instagram) using next-auth in combination with Prisma and MongoDB. However, I have encountered an issue while attempting to sign up using any of these providers. Below is the snippet from my nextauth.js file:

import NextAuth from "next-auth"

import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaClient } from '@prisma/client';

import InstagramProvider from "next-auth/providers/instagram";
import TwitterProvider from "next-auth/providers/twitter";
import FacebookProvider from "next-auth/providers/facebook";

const prisma = new PrismaClient();


export default NextAuth({
  adapter: PrismaAdapter(prisma),
  
  providers: [
    InstagramProvider({
      clientId: process.env.INSTAGRAM_CLIENT_ID,
      clientSecret: process.env.INSTAGRAM_CLIENT_SECRET
    }),
    TwitterProvider({
      clientId: process.env.TWITTER_CLIENT_ID,
      clientSecret: process.env.TWITTER_CLIENT_SECRET,
      version: "2.0",
    }),
    FacebookProvider({
      clientId: process.env.FACEBOOK_CLIENT_ID,
      clientSecret: process.env.FACEBOOK_CLIENT_SECRET
    }),

  ],
  session: {
    strategy: 'jwt',
  },
  
});

I have gone through the process of reinstalling all dependencies in an attempt to resolve the issue, as I couldn't identify any other potential causes so far. Initially, I suspected the dependencies might be the culprit, hence the reinstallation.

Answer №1

The issue lies within your adapter in the [nextauth].js file or wherever you have defined the prisma instance.

Take a look at these related discussions:

Answer №2

By incorporating

@map("provider_account_id")
into the providerAccountId attribute within the Account model in the schema.prisma file, I successfully resolved the issue.

reference: bassem97's recommended approach

Answer №3

The problem was identified within the Prisma schema and resolved by consulting the authentication documentation related to Prisma and MongoDB.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Next.js does not transfer routing parameters

After developing an application in Next.js version 9.4.4, my folder structure looks like this: pages [id] index.js index.js Whenever I send a request to localhost:3000/something, it always redirects to the index page. However, when I try to log this inf ...

I am encountering an issue where I am using Getserversideprops within a page to retrieve data from Strapi, but I am consistently

Having an issue with fetching data from a Strapi backend using getServerSideProps in Next.js. The data appears to be undefined, even though the link works correctly in the browser. I am fetching inside a page, not a component, following the method descri ...

Top strategy for monitoring a user's advancement in reading different text segments

If you are familiar with zyBooks, I am looking to implement a similar feature where users can track the sections they have read and mark them as completed with a button. However, I am struggling conceptually with determining how best to structure my mongo ...

Looking to create dynamic pages on NextJS without relying on fixed paths?

I am looking to create a unique user experience by offering discounts on my website based on the users' citizenship ID numbers. By using their ID number, I can customize the discount amount according to factors such as location, age, and gender. User ...

Utilizing Next.js to Import a Function from a Path Stored within an Environment Variable

I'm having trouble importing a function whose path is stored in an environment variable Current import statement: import { debug } from '../lib/site-A/utils' Expected import statement: import { debug } from process.env.DEBUG_PATH In my ...

Discover a step-by-step guide on incorporating a swipe animation into a responsive carousel

I'm currently using next JS in combination with tailwind css and the react-responsive-carousel package. The issue I'm facing is that when I swipe through the images, they transition horizontally without any additional effects such as fade or ease ...

Using the MUI `useTheme` hook within a server-side component

Is there a way to utilize my MUI (material ui) theme definition in a server component without using the 'use client' directive? Typically, I rely on the handy useTheme hook. However, this approach requires me to convert it into a client component ...

Customize the classes depending on the route in NEXTJS

I have a Header.JS file that contains a navigation component. Depending on the page, I may need to render either the left menu or the right menu. If the current path is "/", I want to render: <Navigation menu={menus?.left_menu} ...

What is the best approach to retrieve and showcase data from a Strapi API using useState in React?

I have a task to retrieve and display the titles, prices, descriptions, and allergies from the Strapi API located at http://localhost:1337/api/pizzasarpsborgs. Link to API However, I'm uncertain how to handle the response data. Can anyone provide gu ...

Error in Next.js 13 Dynamic Route: The specified parameter (slug) was not provided as a valid string in the generateStaticParams function for the route /[lng]/blog/[slug]

I am currently tackling a project in Next.js 13 that involves incorporating support for internationalization and setting up a blog. This is the folder structure of the app: app --[lang] ----blog ------page.tsx ------[slug] --------page.tsx The [lang] sect ...

How can I make the fullcalendar 'moreLink' popover stay open when clicking outside?

Currently, I am working with FullCalendar v6 on nextjs. One built-in feature that caught my attention is the event popover that appears when there are too many events, accessible by clicking "more." However, I am facing a challenge in preventing this pop ...

Implementing fetch API in middleware in Next.js

Currently, I am utilizing a middleware in Next.js (https://nextjs.org/docs/advanced-features/middleware) for my project. However, I am encountering an issue when trying to send a request to the API. The error message displayed is: "unhandledRejection: Ty ...

process.cwd() Varying paths in different operational environments

I am currently utilizing Next.js version 14. Within each page folder, there is a file named meta.md, which I access using fs. The content of these files is as follows: const postsDirectoryPath = process.cwd(); In the development environment, the files ar ...

Error: The variable _ is undefined when trying to use the .map() function on an array

While working on my project, I encountered a "ReferenceError: _ is not defined" when using the .map function in this code snippet: arr.map(async (elem) => { ... }); I couldn't find any explicit mention of "_" in my code. The error trace pointed me ...

The formation of Prisma models -

Apologies for my beginner-level question, but I'm curious to know if it's possible in the schema.prisma definition to require a column to be the sum of two other columns? For example, can we enforce that column 1 equals the sum of column 2 and c ...

What is the counterpart of window.location.pathname in the Next.js router?

When using router.push("/login") in Next.js or window.location.pathname, the query string params get stripped out. Is there a way to change paths while preserving the query string params in Next.js? import router from "next/router"; router.push("/login" ...

Exploring the process of retrieving data from localStorage in Next.js 13

Having recently delved into the realm of Next JS, I've encountered a hurdle when it comes to creating middleware within Next. My aim is to retrieve data from local storage, but I keep hitting roadblocks. middleware.ts import { key, timeEncryptKey, to ...

Issues encountered with Nextjs 13.4 and Next-Auth 4.2 regarding the signIn("credentials", { }); functionality not functioning as expected

When using next-auth credentials in my current project, I encountered an issue with the signIn() function from next-auth/react. It appears that the redirection to the admin page persists regardless of whether the login details are correct or not. {error: n ...

Troubleshooting Cross-Origin Resource Sharing problem in launching Next.js 13 application on Vercel with MongoDB integration

Having trouble with CORS errors while trying to deploy my Next.js 13 application on Vercel, especially when using a MongoDB-based API. The API is for basic CRUD operations, and here is how I currently have my fetch set up: // individual PUT/DELETE/GET ...

The sorting function is failing to produce the expected order of values

Currently, I am working on a feature to sort an array of objects based on user-selected values. Strangely, the function returns the same result no matter which case is executed. I have thoroughly checked each case and they are functioning correctly; howeve ...