import { appSiteAssociation, setupLinkPage } from '../src/passkeys.js'; // Protect retired website routes without touching R2 artifacts. export function isRetiredNativeRoute(pathname) { let path = pathname; try { path = decodeURIComponent(pathname); } catch {} return /^\/(?:downloads\/.+|appcast[^/]*\.xml\/?)(?:$)/i.test(path); } export async function onRequest(context) { const { request, next } = context; const url = new URL(request.url); const path = url.pathname; // Passkeys: Apple's app-site association (webcredentials) and where a setup link lands in a browser. if (path === '/.well-known/apple-app-site-association') return appSiteAssociation(); if (path === '/passkey' || path === '/passkey/') return setupLinkPage(); if (path === '/analytics-consent.gif') { return new Response(null, { status: 410, headers: { 'Cache-Control': 'no-store' } }); } if (isRetiredNativeRoute(path)) { return new Response(request.method === 'HEAD' ? null : 'Jobley is now website-only. Find volunteer work at https://jobley.ai/volunteer/.', { status: 410, headers: { 'Cache-Control': 'no-store', 'Content-Type': 'text/plain; charset=utf-8', 'X-Content-Type-Options': 'nosniff', 'X-Robots-Tag': 'noindex', }, }); } return next(); }