MCPcopy Create free account
hub / github.com/hashintel/hash / resolveClientIp

Function resolveClientIp

apps/petrinaut-website/api/chat.ts:72–81  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

70 * See https://vercel.com/docs/edge-network/headers/request-headers
71 */
72const resolveClientIp = (request: Request): string | null => {
73 const forwardedFor = request.headers.get("x-forwarded-for");
74 if (forwardedFor) {
75 const first = forwardedFor.split(",")[0]?.trim();
76 if (first) {
77 return first;
78 }
79 }
80 return request.headers.get("x-vercel-forwarded-for");
81};
82
83const checkRateLimit = (clientIp: string): boolean => {
84 const now = Date.now();

Callers 1

fetchFunction · 0.85

Calls 2

splitMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected