diff --git a/src/middleware.ts b/src/middleware.ts index 84cf7b2..4a51854 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -61,6 +61,18 @@ export const onRequest = defineMiddleware(async (context, next) => { const method = context.request.method; const path = context.url.pathname; + // Normalize paths corrupted by a trailing stray ")" before routing. + // These come from monitors/links that captured a URL together with a + // closing parenthesis — e.g. "https://workroot.in/)" copied out of the + // markdown/shell form "(https://workroot.in/)". Without this, every such + // probe hits a non-existent route and 404s on a loop (recurring "GET /)"). + // Stripping the trailing paren(s) lets the request resolve to the intended + // route (e.g. "/)" -> "/"), so the monitor gets a 301 -> 200 instead. + const normalizedPath = path.replace(/\)+$/, ''); + if (normalizedPath !== path && normalizedPath.length > 0) { + return context.redirect(`${normalizedPath}${context.url.search}`, 301); + } + // CSRF origin validation for API mutations if (!validateCsrfOrigin(context.request, context.url)) { logger.warn('middleware', 'CSRF origin check failed', { diff --git a/src/pages/index.astro b/src/pages/index.astro index e8e0cbf..7ffc0b2 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -236,6 +236,23 @@ const techStack = [ + +
+