Created
November 17, 2020 09:00
-
-
Save dhsathiya/b24761556820a36ae77d75c31c877256 to your computer and use it in GitHub Desktop.
Get Real-IP of a user in a separate request header with CloudFront <-> Lambda@Edge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Real-IP of a user in a separate request header with CloudFront <-> Lambda@Edge | |
'use strict'; | |
exports.handler = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
const headers = request.headers; | |
headers['true-client-ip'] = [{ | |
key: 'True-Client-IP', | |
value: request['clientIp'] | |
}]; | |
callback(null, request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment