mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
Update the shorturl redirect to support paths and query arguments
This commit is contained in:
parent
d77141a94a
commit
93a5a4e210
@ -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 = `
|
const body = `
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head><title>301 Moved Permanently</title></head>
|
<head><title>Gender Dysphoria Bible</title></head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<center><h1>301 Moved Permanently</h1></center>
|
<h1>Redirecting...</h1>
|
||||||
<hr><center>CloudFront Lambda@Edge</center>
|
<a href="${url}">Click here if you are not redirected.</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
@ -15,11 +19,11 @@ exports.handler = async () => {
|
|||||||
status: '301',
|
status: '301',
|
||||||
statusDescription: `Redirecting to www domain`,
|
statusDescription: `Redirecting to www domain`,
|
||||||
headers: {
|
headers: {
|
||||||
location: [ {
|
location: [{
|
||||||
key: 'Location',
|
key: 'Location',
|
||||||
value: `https://genderdysphoria.fyi`,
|
value: url.toString()
|
||||||
} ],
|
}],
|
||||||
},
|
},
|
||||||
body,
|
body
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,6 @@ provider "namecheap" {
|
|||||||
user_name = var.namecheap.username
|
user_name = var.namecheap.username
|
||||||
api_user = var.namecheap.username
|
api_user = var.namecheap.username
|
||||||
api_key = var.namecheap.apikey
|
api_key = var.namecheap.apikey
|
||||||
client_ip = chomp(data.http.externalip.body)
|
client_ip = chomp(data.http.externalip.response_body)
|
||||||
use_sandbox = false
|
use_sandbox = false
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ resource "aws_cloudfront_origin_access_identity" "origin_access_identity" {
|
|||||||
|
|
||||||
resource "aws_cloudfront_distribution" "site" {
|
resource "aws_cloudfront_distribution" "site" {
|
||||||
origin {
|
origin {
|
||||||
domain_name = aws_s3_bucket.src.bucket_regional_domain_name
|
domain_name = aws_s3_bucket_website_configuration.src.website_endpoint
|
||||||
origin_id = "S3-Website-${aws_s3_bucket.src.website_endpoint}"
|
origin_id = "S3-Website-${aws_s3_bucket_website_configuration.src.website_endpoint}"
|
||||||
|
|
||||||
custom_origin_config {
|
custom_origin_config {
|
||||||
origin_protocol_policy = "http-only"
|
origin_protocol_policy = "http-only"
|
||||||
@ -30,7 +30,7 @@ resource "aws_cloudfront_distribution" "site" {
|
|||||||
default_cache_behavior {
|
default_cache_behavior {
|
||||||
allowed_methods = ["GET", "HEAD"]
|
allowed_methods = ["GET", "HEAD"]
|
||||||
cached_methods = ["GET", "HEAD"]
|
cached_methods = ["GET", "HEAD"]
|
||||||
target_origin_id = "S3-Website-${aws_s3_bucket.src.website_endpoint}"
|
target_origin_id = "S3-Website-${aws_s3_bucket_website_configuration.src.website_endpoint}"
|
||||||
|
|
||||||
forwarded_values {
|
forwarded_values {
|
||||||
query_string = false
|
query_string = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user