v4.1 - Admin/onboarding

This commit is contained in:
2026-05-18 22:25:43 +12:00
parent 6ff970015f
commit 541ae2eeec
79 changed files with 11544 additions and 1007 deletions
+33
View File
@@ -0,0 +1,33 @@
import type { Handle } from '@sveltejs/kit';
const ADMIN_HOSTNAME = 'admin.goodwalk.co.nz';
const ADMIN_PATH = '/owner/welcome';
function isAdminHost(hostname: string | undefined | null): boolean {
if (!hostname) return false;
return hostname.toLowerCase() === ADMIN_HOSTNAME;
}
export const handle: Handle = async ({ event, resolve }) => {
const onAdminHost = isAdminHost(event.url.hostname);
const path = event.url.pathname;
// The admin host serves the dashboard at its root.
if (onAdminHost && (path === '/' || path === '')) {
return new Response(null, {
status: 302,
headers: { location: ADMIN_PATH },
});
}
// Block the admin dashboard from the public marketing host so it only
// lives on admin.goodwalk.co.nz in production. Localhost and the
// onboarding subdomain are still allowed for development and migration.
const hostname = event.url.hostname.toLowerCase();
const isPublicMarketingHost = hostname === 'goodwalk.co.nz' || hostname === 'www.goodwalk.co.nz';
if (isPublicMarketingHost && path.startsWith('/owner/')) {
return new Response('Not Found', { status: 404 });
}
return resolve(event);
};