Reputation: 715
I learned ReactJS and NextJS, but I am having trouble implementing rate-limiting/throttling in NextJS. I want there to be a limit on the number of times the user can access certain requests per period of time.
Upvotes: 5
Views: 20315
Reputation: 490
Update 2022-Jul-13: As of Next.js v12.2.0
, middleware is now stable.
In the latest version of nextjs it is possible through https://nextjs.org/docs/middleware even though it is still in beta.
You can find examples here https://github.com/vercel/examples/tree/main/edge-functions
Your specific use case examples:
Upvotes: 2
Reputation: 125
exist and answer for that on the next link.
https://github.com/vercel/next.js/discussions/12134#discussioncomment-6792
And for the last alternative, you can add an express library into a nextjs middleware
https://nextjs.org/docs/api-routes/api-middlewares
Upvotes: 2