From 758327f0c6eaeb91a1aa387b15f76a45b95d6e16 Mon Sep 17 00:00:00 2001 From: Adam Moussa Date: Thu, 24 Sep 2026 17:20:51 -0400 Subject: [PATCH] fix(careers): return 301s for retired job URLs Send the old careers paths to the Paychex portal from the viewer-request function so clients get a permanent redirect instead of the HTML stub. --- terraform/cloudfront.tf | 7 ++++--- terraform/functions/directory-index.js | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/terraform/cloudfront.tf b/terraform/cloudfront.tf index e30e986..e9938a0 100644 --- a/terraform/cloudfront.tf +++ b/terraform/cloudfront.tf @@ -6,12 +6,13 @@ resource "aws_cloudfront_origin_access_control" "site" { signing_protocol = "sigv4" } -# Viewer-request rewrite so pretty URLs (/sustainability/) fetch S3 key -# sustainability/index.html. default_root_object only covers "/". PLAT-105. +# Viewer-request: 301 retired /careers job URLs to the Paychex portal, then +# rewrite pretty URLs (/sustainability/) to index.html. default_root_object +# only covers "/". PLAT-105. resource "aws_cloudfront_function" "directory_index" { name = "seahaven-site-prod-directory-index" runtime = "cloudfront-js-2.0" - comment = "Rewrite directory and extensionless URIs to index.html" + comment = "301 retired job URLs and rewrite directory URIs to index.html" publish = true code = file("${path.module}/functions/directory-index.js") } diff --git a/terraform/functions/directory-index.js b/terraform/functions/directory-index.js index 5b6e0e5..40c5758 100644 --- a/terraform/functions/directory-index.js +++ b/terraform/functions/directory-index.js @@ -1,6 +1,33 @@ +var PORTAL_URL = "https://jobs.appone.com/seahaven"; + +// Retired local job pages. Redirect before the directory-index rewrite so +// these paths never fall through to the HTML stubs in S3. +var RETIRED_JOB_URIS = { + "/careers/dispatcher": 1, + "/careers/dispatcher/": 1, + "/careers/dispatcher/index.html": 1, + "/careers/scheduling-coordinator": 1, + "/careers/scheduling-coordinator/": 1, + "/careers/scheduling-coordinator/index.html": 1, + "/careers/traveling-maintenance-assistant": 1, + "/careers/traveling-maintenance-assistant/": 1, + "/careers/traveling-maintenance-assistant/index.html": 1 +}; + function handler(event) { var request = event.request; var uri = request.uri; + + if (RETIRED_JOB_URIS[uri]) { + return { + statusCode: 301, + statusDescription: "Moved Permanently", + headers: { + location: { value: PORTAL_URL } + } + }; + } + var last = uri.substring(uri.lastIndexOf("/") + 1); // S3 OAC has no directory index. default_root_object only covers "/".