arashi-dev
arashi-dev3y ago

Rate limit in TRPC and NextJS?

Hello, I am using TRPC with nextjs without express adapter. I am wondered what is the best and free solution to rate limit some of the procedures? I found the lru-cache approach for nextjs but thought if there is a better way...
2 Replies
Alex / KATT 🐱
Make it as a middleware As in a trpc middleware Then you can use some oss library for the time window and scoring You'll have access to ctx to generate an id for the caller, either by the user session or the request's IP, and use the path as a key
arashi-dev
arashi-devOP3y ago
Alright, thank you for your response :)) @alex / KATT

Did you find this page helpful?