Next.js Discord

Discord Forum

An error at the first load of dynamic pages.

Unanswered
Great Dane posted this in #help-forum
Open in Discord
Great DaneOP
I have the next problem with dynamic routes after deployment (vps nginx). At the first load, an error occurs, and the error.ts page is loaded. But if i reload it, then the page opens, and other pages are also opened. For example, at the first load "/news/1" or "/news/2" an error page opens. However, when repeated loading it opens, and also pages with other IDs. And this happens with any dynamic pages at the first load, if before this the cache is cleaned. When working on a local server, there is no such problem, and in general there are no problems. What could be the reason?

1 Reply

Northeast Congo Lion
Maybe you didn't handling the first fetch. If you have a first fetch inside a useEffect() the data will take a time to load, so if you don't have data, show a loading to the user, then only when the fetch ends show the data