using getServerSideProps to do fetch internal API data, the TTFb time is really high, my page run slow.
So I'm searching for other fetching strategies, my MongoDB data is not large (DATABASE SIZE: 33.84KB), and data does not change often, the best way I think is the State generation page, the total should only 25 pages being generated, but the problem is getStateProps()
method can't fetch internal API (development works, production not).
I try:
- useEffect : slower than getServerProps
- export the MongoDB file to data.js and put it into the project as a fake API: it can work with getStaticProp but the date I still want to storge in the database.
- Host API to other domains as external: getStateProps works, approach weird
- hard code every 25 page (X)
Question:
- the method to improve the code and TTFB
- Why getStateProps can't fetch internal API, why design like that.