Skip to content

Commit

Permalink
Update index.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeMalkin authored Dec 19, 2023
1 parent aed29e0 commit 215efc0
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions docspace-reverse-proxy/index.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
'use strict';

// Redirect from DS to WS if match
const workspaceRegex = /(\/products\/|\/addons\/|.aspx)/i;
export const handler = async (event, context, callback) => {
console.log(JSON.stringify(event));

if (workspaceRegex.test(request.uri))
{
const newurl = `https://${tenantDomain.replace('onlyoffice.io', 'teamlab.info')}${request.uri}?${request.querystring}`;
console.log("redirect to: %s", newurl);
const response = {
status: '302',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location',
value: newurl,
}],
},
};
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;

return callback(null, response);
// Redirect from DS to WS if match
const workspaceRegex = /(\/products\/|\/addons\/|.aspx)/i;

}
if (workspaceRegex.test(request.uri))
{
const newurl = `https://${tenantDomain.replace('onlyoffice.io', 'teamlab.info')}${request.uri}?${request.querystring}`;
console.log("redirect to: %s", newurl);
const response = {
status: '302',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location',
value: newurl,
}],
},
};

return callback(null, response);

}
};

0 comments on commit 215efc0

Please sign in to comment.