Skip to content

Commit

Permalink
ADD docspace viewer request
Browse files Browse the repository at this point in the history
  • Loading branch information
YaroslavPshenichnikov committed Dec 19, 2023
2 parents f42b737 + 215efc0 commit a192034
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions docspace-reverse-proxy/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

export const handler = async (event, context, callback) => {
console.log(JSON.stringify(event));

// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;

// 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);

}
};
2 changes: 1 addition & 1 deletion test-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Resources:
docspacereverseproxy:
Type: AWS::Serverless::Function
Properties:
CodeUri: docspace-reverse-proxy/
CodeUri: docspace-viewer-request/
Description: ""
MemorySize: 128
Timeout: 3
Expand Down

0 comments on commit a192034

Please sign in to comment.