fix(careers): return 301s for retired job URLs (DEV-297) (#68)
Some checks failed
Deploy / deploy (push) Has been cancelled

* 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.

* fix(careers): match retired job redirects case-insensitively

CloudFront does not normalize URI case, so a mixed-case old job link skipped the 301 and missed the lowercase S3 stub.
This commit is contained in:
Adam Moussa 2026-09-24 21:31:30 +00:00 • committed by GitHub
parent ff66171782
commit f194d65ee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 3 deletions

View file

@ -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")
}

View file

@ -1,6 +1,34 @@
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;
// CloudFront does not normalize URI case. The S3 keys are lowercase.
if (RETIRED_JOB_URIS[uri.toLowerCase()]) {
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 "/".