Add imports for User model to routes where needed #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you try to deploy the project using Vercel - you will be getting errors on first load when fetching data of prompts. I've been seeing this errors on Feed and Profile components on first load of the page (When serverless functions are on cold boot) or after some delay when the web site was inactive (about after 15-30 min).
The server error message is
MissingSchemaError: Schema hasn't been registered for model "User". Use mongoose.model(name, schema)
.To fix the problem you need to add Imports of the User model where you are using .populate("creator") method.
What is interesting about this issue - is that you're not getting this errors in local development runs or even after site was active after some reloads.
The material I was using to fix the problem: https://dev.to/janetthedev/using-mongooses-populate-in-nextjs-4jof