Skip to content

Commit

Permalink
merge script from live lambda in dev
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjeffers committed Oct 24, 2023
1 parent 52ab48d commit b2b3b64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ const referenceData = {
s3Prefixes: ['/blog/', '/docs/', '/legal/', '/articles/', '/dev-tools/']
}

const handler = (event, context, callback) => {
exports.handler = (event, context, callback) => {
var req = event.Records[0].cf.request;
var uri = req.uri;
var result = req;
Expand All @@ -549,9 +549,9 @@ const handler = (event, context, callback) => {

if (redirect !== null) {
result = redir(redirect);
} else {
req.uri = calculateURI(uri);
}

req.uri = calculateURI(uri);
}

callback(null, result);
Expand Down Expand Up @@ -615,7 +615,5 @@ function calculateURI(uri) {
}

function redir(loc) {
return {statusCode:301,statusDescription:'Moved',headers:{'location':[{value: loc}]}}
return {status:301,statusDescription:'Moved',headers:{'location':[{key: 'Location', value: loc}]}}
}

exports.handler = handler;
2 changes: 1 addition & 1 deletion src/cloudfront/lambda-request-handler/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const makeRequest = (path) => {
}

const makeRedirect = (path) => {
return {statusCode: 301, statusDescription: 'Moved', headers: {'location': [{value: path}]}};
return {status: 301, statusDescription: 'Moved', headers: {'location': [{key: "Location", value: path}]}};
};

const makePassThroughRequest = (path) => {
Expand Down

0 comments on commit b2b3b64

Please sign in to comment.