Next.js Discord

Discord Forum

middleware with mongoose

Answered
Yellowstripe scad posted this in #help-forum
Open in Discord
Yellowstripe scadOP
hey all!
i know that there is a problem for mongoose to run on edge fucntions like middleware but still - is there any what to use middleware with mongoose? if no - what alternative would you recommend to use in the middleware for connecting to the db for authenticating the user (using mongodb)?
thanks in advance!
Answered by James4u
https://nextjs.org/docs/pages/api-reference/edge
Check this link to see what you can use.
View full answer

5 Replies

Next.js team is still working on limited edge library usage - no way to use mongoose in the middleware
apply your auth logic directly inside api route, server components
@James4u apply your auth logic directly inside api route, server components
Yellowstripe scadOP
got it, Thanks alot!!!
btw - is there any library i can use with mongodb and the middleware? the idea is to maybe have another lib just for the authenticate with the middleware
https://nextjs.org/docs/pages/api-reference/edge
Check this link to see what you can use.
Answer
@James4u https://nextjs.org/docs/pages/api-reference/edge Check this link to see what you can use.
Yellowstripe scadOP
you are absolutly AWSOME!!!!! Thanks alot!!