agent: Fix repeated 404 requests to malformed '/)' path

This commit is contained in:
platform-mcp
2026-06-17 20:15:35 +05:30
parent 9a523c038c
commit 7f3d94178d
4 changed files with 31 additions and 2 deletions
+12
View File
@@ -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', {
+17
View File
@@ -236,6 +236,23 @@ const techStack = [
</a>
</div>
<!-- Tertiary click-to-call — one-tap dial for visitors who'd rather
talk now. Min 48px tap target per WCAG 2.5.5 / Apple HIG. -->
<p class="mt-6 text-base sm:text-lg text-secondary-200 opacity-0 animate-slide-up flex flex-wrap items-center justify-center gap-x-2 gap-y-1" style="animation-delay: 0.85s;">
<span>Prefer to talk now?</span>
<a
href="tel:+919561417403"
data-cta="hero-call"
aria-label="Call WorkRoot at +91 95614 17403"
class="inline-flex min-h-[48px] items-center gap-2 rounded-lg px-2 font-semibold text-white underline decoration-primary-400/60 underline-offset-4 transition-colors hover:text-primary-200 hover:decoration-primary-300 focus:outline-none focus:ring-2 focus:ring-primary-400 focus:ring-offset-2 focus:ring-offset-secondary-900"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
+91 95614 17403
</a>
</p>
<!-- Micro-trust line under CTAs -->
<p class="mt-6 text-sm sm:text-base text-secondary-300 opacity-0 animate-slide-up flex flex-wrap items-center justify-center gap-x-3 gap-y-2" style="animation-delay: 0.9s;" aria-label="Trust signals">
<span class="inline-flex items-center gap-2">
+1 -1
View File
@@ -211,7 +211,7 @@ const lastUpdated = 'March 20, 2026';
<div class="bg-secondary-900/50 border border-secondary-800 rounded-xl p-6">
<p class="text-secondary-300"><strong class="text-white">WorkRoot IT Solutions</strong></p>
<p class="text-secondary-300">Email: admin@workroot.in</p>
<p class="text-secondary-300">Phone: +91 9561417403</p>
<p class="text-secondary-300">Phone: <a href="tel:+919561417403" class="text-primary-400 hover:underline">+91 9561417403</a></p>
<p class="text-secondary-300">Address: At Post Rajapur Shantinagar, Taluka Khatav, Dist Satara, MH 415503</p>
</div>
</div>
+1 -1
View File
@@ -297,7 +297,7 @@ const lastUpdated = 'March 20, 2026';
<div class="bg-secondary-900/50 border border-secondary-800 rounded-xl p-6">
<p class="text-secondary-300"><strong class="text-white">WorkRoot IT Solutions</strong></p>
<p class="text-secondary-300">Email: admin@workroot.in</p>
<p class="text-secondary-300">Phone: +91 9561417403</p>
<p class="text-secondary-300">Phone: <a href="tel:+919561417403" class="text-primary-400 hover:underline">+91 9561417403</a></p>
<p class="text-secondary-300">Address: At Post Rajapur Shantinagar, Taluka Khatav, Dist Satara, MH 415503</p>
</div>
</div>