Closed steveatkoan closed 9 months ago
you should be able to look at the event.identity.sourceIp or event.http.sourceIp Depending on if we are using the REST api or HTTP api gateway respectively. https://github.com/awsdocs/aws-lambda-developer-guide/blob/main/sample-apps/nodejs-apig/event.json https://github.com/awsdocs/aws-lambda-developer-guide/blob/main/sample-apps/nodejs-apig/event-v2.json
add near line 42
const remoteAddress = event.requestContext?.http?.sourceIp || event.requestContext?.identity?.sourceIp || undefined
line 102
app.inject({ method, url, query, payload, headers, remoteAddress }
the remote address should be in the x-forwarded-for header
v3.5.0 should also use the sourceIp as remoteAddress
So fast! Thanks heaps. Very helpful!
Thank you
Prerequisites
🚀 Feature Proposal
Hi How possible is it to get the remote IP from the aws lambda environment (somewhere?) and include that in the app.inject() call?
Motivation
I'm using fastify/rate-limit because I want custom control over the rate limits applied. But because I don't know the remote IP address it thinks the whole world is 127.0.0.1 when a request comes from api gateway / lambda
Example
No response