diff --git a/server/notification-routes.ts b/server/notification-routes.ts index 3b718ab..4562c07 100644 --- a/server/notification-routes.ts +++ b/server/notification-routes.ts @@ -13,9 +13,8 @@ export const notificationRouter = new Hono(); // Proxy all notification requests to encryptid notificationRouter.all("/*", async (c) => { - const path = `/api/notifications${c.req.path === "/" ? "" : c.req.path}`; - const search = new URL(c.req.url).search; - const targetUrl = `${ENCRYPTID_URL}${path}${search}`; + const url = new URL(c.req.url); + const targetUrl = `${ENCRYPTID_URL}${url.pathname}${url.search}`; const headers = new Headers(c.req.raw.headers); headers.delete("host"); @@ -32,8 +31,8 @@ notificationRouter.all("/*", async (c) => { } catch (e: any) { console.error("[notifications proxy] Failed to reach encryptid:", e?.message); // Return safe fallbacks instead of hanging - if (c.req.path === "/count") return c.json({ unreadCount: 0 }); - if (c.req.path === "/") return c.json({ notifications: [] }); + if (url.pathname.endsWith("/count")) return c.json({ unreadCount: 0 }); + if (url.pathname === "/api/notifications") return c.json({ notifications: [] }); return c.json({ error: "Notification service unavailable" }, 503); } });