Are you deploying a nextjs app ? and faced this issue ?

Application error: a server-side exception has occurred (see the server logs for more information).
Digest: 4231503238.
When you check the logs you find that it is a schema error.
MissingSchemaError: Schema hasn't been registered for model "Category". Use mongoose.model(name, schema).
const blogs = await Blog.find({}).populate("author category");This is caused by mongoose not finding model when populating the data.
Here is the fix.
Import your schema (model) to where it is being used.
import "@/database/category.model"
import "@/database/auth.model"Basically, The NextJS page that is getting data from the server with getServerSideProps via database call needs to have the referenced model file imported.
This way by importing the file containing the referenced model at the top of your page file you are registering the model before you use it down below inside getServerSideProps.












