I have a change request for a static website that is live on AWS cloudfront.
Basically in the page there's a link to https://example.com/schedule
if the user clicks on that link we want it to show a page on calendly in the form https://calendly.com/company/schedule
I wouldn't have a clue where to start with this. Any suggestions?
this is what I got so far, calling callback as I see on many tutorials doesn't seem to work. also on AWS the tutorials fail to build.
'use strict';
function handler(event, context, callback) {
var uri = event.request.uri
console.log(uri);
//if URI matches to 'pretty-url' then redirect to a different URI
if(uri == "/schedule"){
console.log('it\'s schedule');
//Generate HTTP redirect response to a different landing page.
var redirectResponse = {
status: '301',
statusDescription: 'Moved Permanently',
headers: {
'location': [{
key: 'Location',
value: 'https://calendly.com/company/schedule',
}],
'cache-control': [{
key: 'Cache-Control',
value: "max-age=7200"
}],
},
};
console.log(redirectResponse);
// callback(null, redirectResponse);
console.log('returning');
return event.response;
} else {
// for all other requests proceed to fetch the resources
return event.request;
}
};