Skip to content

Instantly share code, notes, and snippets.

@htnosm
Created September 24, 2021 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save htnosm/2c51a70f0e361056d1fd63321afba4fa to your computer and use it in GitHub Desktop.
Save htnosm/2c51a70f0e361056d1fd63321afba4fa to your computer and use it in GitHub Desktop.
Lambda@Edge origin-request trigger to change HTTP Host Header.
'use strict';
exports.handler = (event, context, callback) => {
console.log('event:' + JSON.stringify(event));
// Get contents of request
const request = event.Records[0].cf.request;
// Rewrite
request.headers.host[0].value = '${rewrite_value}';
console.log('request headers:' + JSON.stringify(request.headers));
return callback(null, request);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment