Skip to content

Instantly share code, notes, and snippets.

@croesus
croesus / index.js
Created April 29, 2018 15:06
CloudFront Edge Lambda redirect non-www to www
'use strict';
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
var params = '';
if(('querystring' in request) && (request.querystring.length>0)) {
params = '?'+request.querystring;
}