Skip to content

Commit cb9df92

Browse files
committed
Fix retrieving the remote address from htttpapi v2 event
1 parent 72103f0 commit cb9df92

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/eventToRequestOptions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const eventToRequestOptions = (event: APIGatewayEvent, ctx?: LambdaContext): InP
4848
} else {
4949
// api gateway request
5050
ssl = true;
51-
const remoteAddressList = event.requestContext && event.requestContext.identity && event.requestContext.identity.sourceIp
51+
const remoteAddressList =
52+
event?.requestContext?.identity?.sourceIp ||
53+
event?.requestContext?.http?.sourceIp
5254
if (remoteAddressList) {
5355
// HTTP API includes the full x-forwarder for chain here and the remote ip is the last element
5456
const items = remoteAddressList.split(',').map(s => s.trim());

0 commit comments

Comments
 (0)