From 7f3d94178d10b6c4ae4fe20be156b4dff4cd0cc1 Mon Sep 17 00:00:00 2001 From: platform-mcp Date: Wed, 17 Jun 2026 20:15:35 +0530 Subject: [PATCH] agent: Fix repeated 404 requests to malformed '/)' path --- src/middleware.ts | 12 ++++++++++++ src/pages/index.astro | 17 +++++++++++++++++ src/pages/privacy.astro | 2 +- src/pages/terms.astro | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) 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 = [ + +

+ Prefer to talk now? + + + +91 95614 17403 + +

+

diff --git a/src/pages/privacy.astro b/src/pages/privacy.astro index dab7af3..c139cbc 100644 --- a/src/pages/privacy.astro +++ b/src/pages/privacy.astro @@ -211,7 +211,7 @@ const lastUpdated = 'March 20, 2026';

WorkRoot IT Solutions

Email: admin@workroot.in

-

Phone: +91 9561417403

+

Phone: +91 9561417403

Address: At Post Rajapur Shantinagar, Taluka Khatav, Dist Satara, MH 415503

diff --git a/src/pages/terms.astro b/src/pages/terms.astro index 7b4c424..249809b 100644 --- a/src/pages/terms.astro +++ b/src/pages/terms.astro @@ -297,7 +297,7 @@ const lastUpdated = 'March 20, 2026';

WorkRoot IT Solutions

Email: admin@workroot.in

-

Phone: +91 9561417403

+

Phone: +91 9561417403

Address: At Post Rajapur Shantinagar, Taluka Khatav, Dist Satara, MH 415503