Skip to content
Discussion options

You must be logged in to vote

If the development mode application is also running in localhost:3000 (this is a bit of a complicated way to say it, keep on reading), it won't work, because, when building the application doesn't even exist.

Think of api/routes as runtime artifacts. The server needs to be running and a request must arrive for them to run.

When getStaticProps runs at build time, there's none of the above. This is why, it's best to abstract the mongo db connections into reusable functions that you can use both in getStaticProps, getServerSideProps and api/routes.

Let's say you mock a server at localhost:3000, then it better continue to exist when ISR happens.

There's nothing forbidding you from reusing the a…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Elindo586
Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Comment options

You must be logged in to vote
1 reply
@icyJoseph
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants