Rate limiting on API endpoints #25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The API has no rate limiting. Vulnerable to brute force attacks on auth endpoints and spam on game endpoints.
What to do
Add rate limiting middleware to the Express API.
Files to change
apps/api/package.json— addexpress-rate-limit(or similar)apps/api/src/app.ts— apply rate limiter middleware. Different limits for:/api/auth/*): strict (e.g. 10 req/min per IP)/api/v1/game/*): moderate (e.g. 60 req/min per IP)/api/v1/health): relaxed or exemptAcceptance criteria
X-RateLimit-Limit,X-RateLimit-Remaining)documentation/decisions.mdNotes
The API runs behind Caddy reverse proxy.
req.ipwill show Caddy's internal IP unlesstrust proxyis configured in Express. The app currently sets up Express inapps/api/src/app.tsviacreateApp()factory function.