Code Monkey home page Code Monkey logo

Comments (6)

Jes015 avatar Jes015 commented on May 24, 2024 1

Interesting

from prisma.

Hugo-Lorenzoni avatar Hugo-Lorenzoni commented on May 24, 2024 1

Same here !

Initially I had this problem :

[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get (webpack-internal:///(middleware)/./node_modules/.prisma/client/index-browser.js:207:15)
at getSessionAndUser (webpack-internal:///(middleware)/./node_modules/@auth/prisma-adapter/index.js:240:44)
at acc. (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/init.js:178:30)
at Module.session (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/actions/session.js:67:36)
at AuthInternal (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/index.js:47:77)
at async Auth (webpack-internal:///(middleware)/./node_modules/@auth/core/index.js:126:34)
at async handleAuth (webpack-internal:///(middleware)/./node_modules/next-auth/lib/index.js:134:29)
at async adapter (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/adapter.js:179:16)
at async C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:110:22
at async runWithTaggedErrors (C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:107:9)
[auth][details]: {}
[auth][error] SessionTokenError: Read more at https://errors.authjs.dev#sessiontokenerror
[auth][cause]: Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get (webpack-internal:///(middleware)/./node_modules/.prisma/client/index-browser.js:207:15)
at getSessionAndUser (webpack-internal:///(middleware)/./node_modules/@auth/prisma-adapter/index.js:240:44)
at acc. (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/init.js:178:30)
at Module.session (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/actions/session.js:67:36)
at AuthInternal (webpack-internal:///(middleware)/./node_modules/@auth/core/lib/index.js:47:77)
at async Auth (webpack-internal:///(middleware)/./node_modules/@auth/core/index.js:126:34)
at async handleAuth (webpack-internal:///(middleware)/./node_modules/next-auth/lib/index.js:134:29)
at async adapter (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/adapter.js:179:16)
at async C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:110:22
at async runWithTaggedErrors (C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:107:9)
[auth][details]: {}

I don't know why because I never tried to use the edge.

So then, i tried to use the neon edge adapter and got the same error as you...

from prisma.

janpio avatar janpio commented on May 24, 2024

Does this cause any problems or error, or is this just a warning?

from prisma.

EddyerDevv avatar EddyerDevv commented on May 24, 2024

It is a warn, but at the end of so many calls or restarts of the page, sometimes it does not restart and I have to restart the server, already in turbo mode because the warn does not appear.

from prisma.

Hugo-Lorenzoni avatar Hugo-Lorenzoni commented on May 24, 2024

I just found out something !
I downgraded next-auth to version 4.24.3 and I have the same error message than the one I posted to abose when I try to use the Nextjs Middleware.
So the problem might come from the fact that the middleware is suppose to run on the edge or something like that and that the prisma adapter is not made for that !

Middleware

import { withAuth } from "next-auth/middleware";
import prisma from "./db";

export default withAuth(
  // `withAuth` augments your `Request` with the user's token.
  function middleware(req) {
    console.log(req.nextauth.token);
  },
  {
    callbacks: {
      authorized: async ({ req: { cookies } }) => {
        const sessionToken = cookies.get("next-auth.session-token")?.value;
        const user = await prisma.session
          .findUnique({ where: { sessionToken } })
          .user();
        console.log(user?.isAdmin);

        return sessionToken != null;
      },
    },
  }
);

Error

⨯ Error: PrismaClient is not configured to run in Vercel Edge Functions or Edge Middleware. In order to run Prisma Client on edge runtime, either:

If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at Object.get (webpack-internal:///(middleware)/./node_modules/.prisma/client/index-browser.js:207:15)
at Object.authorized (webpack-internal:///(middleware)/./src/middleware.ts:18:76)
at handleMiddleware (webpack-internal:///(middleware)/./node_modules/next-auth/next/middleware.js:50:334)
at async Object.options [as handler] (webpack-internal:///(middleware)/./node_modules/next-auth/next/middleware.js:68:31)
at async adapter (webpack-internal:///(middleware)/./node_modules/next/dist/esm/server/web/adapter.js:179:16)
at async (file://C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:110:22)
at async runWithTaggedErrors (file://C:\Code\iot-project\node_modules\next\dist\server\web\sandbox\sandbox.js:107:9)
at async DevServer.runMiddleware (file://C:\Code\iot-project\node_modules\next\dist\server\next-server.js:1062:24)
at async DevServer.runMiddleware (file://C:\Code\iot-project\node_modules\next\dist\server\dev\next-dev-server.js:268:28)
at async NextNodeServer.handleCatchallMiddlewareRequest (file://C:\Code\iot-project\node_modules\next\dist\server\next-server.js:324:26)

from prisma.

EddyerDevv avatar EddyerDevv commented on May 24, 2024

@Hugo-Lorenzoni Well, if you are using neon serverless it works, everything and remove the prism warn from the edge functions, and that works but sometimes the Edge Functions invocations are not completed because of the async await, in the middleware it can serve as protecting routes, I I solved it by removing the middleware, since I won't need it for the moment, but I think it's a Prisma adapter error

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.