I am using Firebase to develop an app that uses Cloud Functions as a REST API internally. My question is, is there an easy way to implement per-IP/per-user rate-limiting sim
Doing this on a per-user basis sounds fairly straightforward:
admin.database().ref(`/userCalls/$uid`).push(ServerValue.TIMESTAMP).admin.database().ref(`/userCalls/$uid`).orderByKey().startAt(Date.now()-60000).I'm not sure if the IP address of the caller is passed to Cloud Functions. If it is, you can do the same logic for the IP address. If it isn't passed, it'll be hard to rate limit in a way that can't be easily spoofed.