forked from github.com/GenderDysphoria.fyi
Update the shorturl redirect to support paths and query arguments
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
exports.handler = async () => {
|
||||
exports.handler = async (event) => {
|
||||
const { uri, querystring } = event?.Records?.[0]?.cf?.request || {};
|
||||
|
||||
const url = new URL(uri, `https://genderdysphoria.fyi`);
|
||||
url.search = new URLSearchParams(querystring);
|
||||
|
||||
const body = `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head><title>301 Moved Permanently</title></head>
|
||||
<head><title>Gender Dysphoria Bible</title></head>
|
||||
<body bgcolor="white">
|
||||
<center><h1>301 Moved Permanently</h1></center>
|
||||
<hr><center>CloudFront Lambda@Edge</center>
|
||||
<h1>Redirecting...</h1>
|
||||
<a href="${url}">Click here if you are not redirected.</a>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
@@ -15,11 +19,11 @@ exports.handler = async () => {
|
||||
status: '301',
|
||||
statusDescription: `Redirecting to www domain`,
|
||||
headers: {
|
||||
location: [ {
|
||||
location: [{
|
||||
key: 'Location',
|
||||
value: `https://genderdysphoria.fyi`,
|
||||
} ],
|
||||
value: url.toString()
|
||||
}],
|
||||
},
|
||||
body,
|
||||
body
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user