Problem
app/api/exchange-rate/route.ts calls CoinGecko on every request (with a 20s Next.js revalidation). CoinGecko's free tier has strict rate limits (30 calls/min). Under moderate traffic, these limits will be exceeded.
app/api/rates/route.ts uses an in-process module-level cache that resets on cold start and is not shared across serverless function instances.
Fix
Use Upstash Redis (already configured in middleware) as a shared cache:
const cached = await redis.get('exchange-rates')
if (cached) return Response.json(JSON.parse(cached))
const fresh = await fetchFromCoinGecko()
await redis.setex('exchange-rates', 60, JSON.stringify(fresh))
return Response.json(fresh)
Impact
Medium — CoinGecko rate limits will cause exchange rate failures under load.
Problem
app/api/exchange-rate/route.tscalls CoinGecko on every request (with a 20s Next.js revalidation). CoinGecko's free tier has strict rate limits (30 calls/min). Under moderate traffic, these limits will be exceeded.app/api/rates/route.tsuses an in-process module-level cache that resets on cold start and is not shared across serverless function instances.Fix
Use Upstash Redis (already configured in middleware) as a shared cache:
Impact
Medium — CoinGecko rate limits will cause exchange rate failures under load.