Next.js Discord

Discord Forum

Middleware not working with Prisma, AuthJs v5 & email provider

Answered
Macao paper wasp posted this in #help-forum
Open in Discord
Macao paper waspOP
I can’t figure out why, but I always get error “ The edge runtime does not support Node.js ‘stream’ module” when I try to create a middleware. Can you guys please help why?
Answered by joulev
prisma doesn't work in middleware. prisma requires nodejs while middleware runs on edge. you have to refactor your logic.
View full answer

9 Replies

@Macao paper wasp I can’t figure out why, but I always get error “ The edge runtime does not support Node.js ‘stream’ module” when I try to create a middleware. Can you guys please help why?
prisma doesn't work in middleware. prisma requires nodejs while middleware runs on edge. you have to refactor your logic.
Answer
@joulev prisma doesn't work in middleware. prisma requires nodejs while middleware runs on edge. you have to refactor your logic.
Macao paper waspOP
Got it, thanks! Just one more quick question please. I have a schema.prisma file with Account, Session, User, VerificationToken entries or models. In my web app users can create webpages, should I create a new schema file for these webpages, or can I make a model in this existing schema.prisma file like CreatedWebsites? Sorry, I'm a begginer
So I don't know if a not authentication related dataset or entry can be declared in the same file
@joulev i don't understand your question. you are trying to add an authentication system for each webpage made by your users? or just need to add database tables to store data for those webpages?
Macao paper waspOP
I just need database tables for objects created by users, and I don't know if I can manage it in the same prisma.scheme file
But I'm guessing it should be fine
Macao paper waspOP
Okay, sorry for this dumb question
Thank you