From 29cfa0b9acad312ae1ebb8a4831a68a00736f551 Mon Sep 17 00:00:00 2001 From: King Omar Date: Fri, 10 Jul 2026 13:35:58 +1000 Subject: [PATCH] Prepare for careersgateway.com.au domain migration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update BASE_URL canonical to careersgateway.com.au (OG tags, sitemaps) - Add careersgateway.com.au + www as custom_domains in wrangler.toml - Add www → apex 301 redirect middleware Co-Authored-By: Claude Sonnet 4.6 --- src/index.js | 11 +++++++++++ src/templates.js | 2 +- wrangler.toml | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7c35b17..d9667bb 100644 --- a/src/index.js +++ b/src/index.js @@ -14,6 +14,17 @@ import { const app = new Hono(); +// ── www → apex redirect ────────────────────────────────────────────────────── +app.use('*', async (c, next) => { + const host = c.req.header('host') || ''; + if (host.startsWith('www.')) { + const url = new URL(c.req.url); + url.hostname = url.hostname.replace(/^www\./, ''); + return c.redirect(url.toString(), 301); + } + await next(); +}); + // ── Auth middleware (attaches user to context) ────────────────────────────── app.use('*', async (c, next) => { c.set('user', await getCurrentUser(c.env, c)); diff --git a/src/templates.js b/src/templates.js index a85f1d3..341c1d8 100644 --- a/src/templates.js +++ b/src/templates.js @@ -142,7 +142,7 @@ const CSS = ` } `; -const BASE_URL = 'https://careers.bored.investments'; +const BASE_URL = 'https://careersgateway.com.au'; const DEFAULT_IMAGE = 'https://careersgateway.com.au/wp-content/uploads/2025/06/pexels-photo-1236421-1236421-scaled.jpg'; const SITE_NAME = 'Careers Gateway Australia'; diff --git a/wrangler.toml b/wrangler.toml index ab8f92c..b663242 100644 --- a/wrangler.toml +++ b/wrangler.toml @@ -6,6 +6,12 @@ compatibility_flags = ["nodejs_compat"] [[custom_domains]] pattern = "careers.bored.investments" +[[custom_domains]] +pattern = "careersgateway.com.au" + +[[custom_domains]] +pattern = "www.careersgateway.com.au" + [[d1_databases]] binding = "DB" database_name = "careersgateway-db"