MCPcopy Index your code
hub / github.com/simstudioai/sim / getClientIp

Function getClientIp

apps/docs/app/api/chat/route.ts:67–71  ·  view source on GitHub ↗

Resolve the client IP from forwarding headers, falling back to a shared bucket.

(req: Request)

Source from the content-addressed store, hash-verified

65
66/** Resolve the client IP from forwarding headers, falling back to a shared bucket. */
67function getClientIp(req: Request): string {
68 const forwarded = req.headers.get('x-forwarded-for')
69 if (forwarded) return forwarded.split(',')[0].trim()
70 return req.headers.get('x-real-ip') ?? 'unknown'
71}
72
73/** Fixed-window check. Returns retry-after seconds when the caller is over the limit, else null. */
74function rateLimit(ip: string, now: number): number | null {

Callers 1

POSTFunction · 0.70

Calls 1

getMethod · 0.65

Tested by

no test coverage detected