-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (23 loc) · 738 Bytes
/
Copy pathindex.js
File metadata and controls
27 lines (23 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const host = headers['host'][0].value;
const path = request.uri;
// 如果請求的路徑已經是 legacy-files/index.html,則不進行導向,避免無限迴圈
if (path === '/legacy-files/index.html') {
callback(null, request);
return;
}
const newurl = `https://${host}/legacy-files/index.html`;
const response = {
status: '302',
statusDescription: 'Found',
headers: {
location: [{
key: 'Location',
value: newurl,
}],
},
};
callback(null, response);
};