From 877a75b053af2eda87e8d83b7373073673303c1a Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Thu, 9 Apr 2026 08:41:32 +0700 Subject: [PATCH] fix: normalize double slashes in URL path for webhook routing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Statuspage deactivated our webhook because requests to //webhook/status/ returned 404 — Hono requires exact path matches. Added middleware that rewrites consecutive slashes before routing, preserving POST body via internal re-dispatch. --- package-lock.json | 50 +---------------------------------------------- src/index.js | 13 ++++++++++++ 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee11d31..9aafe82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "": { "name": "claude-status-webhook", "version": "1.0.0", - "license": "ISC", + "license": "Apache-2.0", "dependencies": { "grammy": "^1.42.0", "hono": "^4.12.12" @@ -697,9 +697,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -717,9 +714,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -737,9 +731,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -757,9 +748,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -777,9 +765,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -797,9 +782,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -817,9 +799,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -837,9 +816,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -857,9 +833,6 @@ "arm" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -883,9 +856,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -909,9 +879,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -935,9 +902,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -961,9 +925,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -987,9 +948,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1013,9 +971,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1039,9 +994,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ diff --git a/src/index.js b/src/index.js index aecb7ce..32cb6bc 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,19 @@ import { setupBot } from "./bot-setup.js"; const app = new Hono(); +// Normalize double slashes in URL path (e.g. //webhook/... → /webhook/...) +// Statuspage may send webhooks with double slashes; rewrite path so routes match. +app.use("*", async (c, next) => { + const url = new URL(c.req.url); + const normalized = url.pathname.replace(/\/\/+/g, "/"); + if (normalized !== url.pathname) { + url.pathname = normalized; + const newReq = new Request(url.toString(), c.req.raw); + return app.fetch(newReq, c.env, c.executionCtx); + } + return next(); +}); + app.get("/", (c) => c.text("Claude Status Bot is running")); app.get("/webhook/setup/:secret", (c) => setupBot(c)); app.post("/webhook/telegram", (c) => handleTelegramWebhook(c));