PrismaClient is unable to run in this browser environment (NextAuth)
Unanswered
Silky ant posted this in #help-forum
Silky antOP
Hi, I can't comprehend how to solve this. If anyone has a clue, please
Error: PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in ``).
If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report
at extendsDb (F:\-\-\.next\server\edge\chunks\_5da35d24._.js:30:12)
at __TURBOPACK__default__export__ (F:\-\-\.next\server\edge\chunks\_5da35d24._.js:61:162)
at new Promise (<anonymous>)
at [project]/src/lib/prisma/index.ts [middleware-edge] (ecmascript) (F:\-\-\.next\server\edge\chunks\_5da35d24._.js:60:5)
at <unknown> (F:\-\-\.next\server\edge\chunks\edge-wrapper_dd67b62a.js:709:27)
at runModuleExecutionHooks (F:\-\-\.next\server\edge\chunks\edge-wrapper_dd67b62a.js:755:9)
at instantiateModule (F:\-\-\.next\server\edge\chunks\edge-wrapper_dd67b62a.js:707:9)
at getOrInstantiateModuleFromParent (F:\-\-\.next\server\edge\chunks\edge-wrapper_dd67b62a.js:640:12)
at esmImport (F:\-\-\.next\server\edge\chunks\edge-wrapper_dd67b62a.js:143:20)
import { PrismaClient } from "@prisma/client";
import extendsDb from "./extendsDb"
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma = globalForPrisma.prisma || new PrismaClient()
if (typeof window === 'undefined') {
new Promise((resolve, reject) => {
extendsDb(prisma)
})
}
//if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
export default prisma;
'use server'
import type { PrismaClient } from '@prisma/client'
async function extendsDb(prisma: PrismaClient) {
prisma.$extends({
name: "anonymous_user",
query: {
user: {
async create({ model, operation, args, query }) {
console.log("anonymous_user create", args);
return query(args);
}
}
}
})
}
export default extendsDb
2 Replies
Silky antOP
due to prisma call inside credentials providers
/solve