Skip to content

Commit 5ca8b4b

Browse files
committed
fix cfn
1 parent 44408bc commit 5ca8b4b

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

cloudformation/main.yml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -894,40 +894,40 @@ Resources:
894894
KeyValueStoreAssociations:
895895
- KeyValueStoreARN: !Sub '${LinkryRecordsCloudfrontStore.Arn}'
896896
FunctionCode: !Sub |
897-
import cf from 'cloudfront';
898-
const kvsId = '${LinkryRecordsCloudfrontStore.Id}';
899-
const kvs = cf.kvs(kvsId);
900-
901-
async function handler(event) {
902-
const request = event.request;
903-
const path = request.uri.replace(/^\/+/, '');
904-
if (path === "") {
905-
return {
906-
statusCode: 301,
907-
statusDescription: 'Found',
908-
headers: {
909-
'location': { value: "https://core.acm.illinois.edu/linkry" }
897+
import cf from 'cloudfront';
898+
const kvsId = '${LinkryRecordsCloudfrontStore.Id}';
899+
const kvs = cf.kvs(kvsId);
900+
901+
async function handler(event) {
902+
const request = event.request;
903+
const path = request.uri.replace(/^\/+/, '');
904+
if (path === "") {
905+
return {
906+
statusCode: 301,
907+
statusDescription: 'Found',
908+
headers: {
909+
'location': { value: "https://core.acm.illinois.edu/linkry" }
910+
}
910911
}
911912
}
912-
}
913-
let redirectUrl = "https://acm.illinois.edu/404";
914-
try {
915-
const value = await kvs.get(path);
916-
if (value) {
917-
redirectUrl = value;
913+
let redirectUrl = "https://acm.illinois.edu/404";
914+
try {
915+
const value = await kvs.get(path);
916+
if (value) {
917+
redirectUrl = value;
918+
}
919+
} catch (err) {
920+
console.log(`KVS key lookup failed for $!{path}: $!{err}`);
918921
}
919-
} catch (err) {
920-
console.log(`KVS key lookup failed for ${path}: ${err}`);
922+
var response = {
923+
statusCode: 302,
924+
statusDescription: 'Found',
925+
headers: {
926+
'location': { value: redirectUrl }
927+
}
928+
};
929+
return response;
921930
}
922-
var response = {
923-
statusCode: 302,
924-
statusDescription: 'Found',
925-
headers: {
926-
'location': { value: redirectUrl }
927-
}
928-
};
929-
return response;
930-
}
931931
AutoPublish: true
932932

933933
AppLinkryCloudfrontDistribution:

0 commit comments

Comments
 (0)