-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aed29e0
commit 215efc0
Showing
1 changed file
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
}; |