We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 501b3d3 commit 24451adCopy full SHA for 24451ad
src/services/ip.ts
@@ -51,6 +51,15 @@ limit 1;
51
52
export function getClientIp(c: Context) {
53
// See: https://docs.rapidapi.com/docs/additional-request-headers.
54
- const forwardedFor = c.req.header("x-forwarded-for")?.split(",")[0].trim();
55
- return forwardedFor || getConnInfo(c).remote.address || "127.0.0.1";
+ const ipForwardedByRapidAPI = c.req
+ .header("x-forwarded-for")
56
+ ?.split(",")[0]
57
+ .trim();
58
+ const ipForwardedByMagicAPI = c.req.header("x-original-forwarded-for");
59
+ return (
60
+ ipForwardedByMagicAPI ||
61
+ ipForwardedByRapidAPI ||
62
+ getConnInfo(c).remote.address ||
63
+ "127.0.0.1"
64
+ );
65
}
0 commit comments