Next.js Discord

Discord Forum

Ratelimit (429) on server while building NextJS static pages

Answered
Spectacled Caiman posted this in #help-forum
Open in Discord
Spectacled CaimanOP
Hi guys!

I have a large-ish NextJS project that builds around 40 dynamic pages with 2-3 requests on average each.

The problem I'm facing right now is that when Next tries to build static pages for me, it fetches data from the server all at once, causing it to hit the rate limit. Increasing rate limit on the server is not an option because its a 3rd party service.

Is there a way I can work around this? I'm using the latest Next 14 and app router so I can't really tweak around with getStaticProps , and I can't find anything on the docs or knowledgebase about this for app router
Answered by riský
View full answer

18 Replies

Spectacled CaimanOP
bump
and maybe make revalidate to something very high if you don't need it to change
ahh it says it still does at build time
Spectacled CaimanOP
Yes
i wanted the create part
Next.js allows you to create or update static pages after you’ve built your site. Incremental Static Regeneration
Spectacled CaimanOP
I contemplated doing something like adding a wait for timeout promise at getStaticProps but i'm using the app router
maybe don't have it fallback blocking?
ohh so you return getStaticPaths with only the ones you want at built time, and if you have fallback: true, it builds them on req
Spectacled CaimanOP
Do those functions still work on the app router?
They seem to be removed from the docs entirely
and replaced with revalidate, dynamic and such
Answer
they have examples of how to do it below in that link
Spectacled CaimanOP
Do those functions still work on the app router though? It seems to be for the pages directory
I linked app dir migration docs
Spectacled CaimanOP
Tahnk you