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"