import model in next js 13 middleware #54920
Replies: 3 comments 5 replies
-
Could you provide more details on how the code responsible for checking It seems that the code related to If you're trying to implement logic to redirect based on the user's login status, you can consider using cookies to determine whether the user is authenticated. Next.js provides a convenient way to work with cookies, and you can refer to the documentation for more details: Using Cookies in Next.js. |
Beta Was this translation helpful? Give feedback.
-
Hey do you get the solution of the problem above???? |
Beta Was this translation helpful? Give feedback.
-
Fix > Optional Chaining.. > mongoose?.models?.model |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using Next.js 13 and I have a User model in my application.
for user authentication, I should import my User model in middleware.js file.
when I import a model in middleware, this error happen.
TypeError: Cannot read properties of undefined (reading 'User')
how can I solve it?
Thank's
Beta Was this translation helpful? Give feedback.
All reactions