From 66b14cfa74d80f3f9718d80fa21a74a9fcc22378 Mon Sep 17 00:00:00 2001 From: fazli Date: Wed, 17 Jun 2026 12:06:35 +0000 Subject: [PATCH] fix(notifications): read camelCase publicKey from VAPID endpoint The backend view returns {"public_key": ...} but the global CamelCaseJSONRenderer rewrites it to {"publicKey": ...} on the wire, so destructuring `public_key` always resolved to undefined and the subscribe path bailed silently. Browsers never registered with the backend, no PushSubscription rows were ever created, and no push notifications fired. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/hooks/usePushNotifications.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/hooks/usePushNotifications.ts b/app/hooks/usePushNotifications.ts index a572331..38d30cc 100644 --- a/app/hooks/usePushNotifications.ts +++ b/app/hooks/usePushNotifications.ts @@ -68,9 +68,11 @@ export function usePushNotifications() { setPermission(perm); if (perm !== "granted") return false; - // Get the VAPID public key from the backend. + // Get the VAPID public key from the backend. The backend's view returns + // {"public_key": ...} but its global CamelCaseJSONRenderer rewrites that + // to {"publicKey": ...} on the wire — so we read camelCase here. const keyRes = await fetch(`${apiBase}/api/notif/v1/push/vapid-public-key/`); - const { public_key: publicKey } = await keyRes.json(); + const { publicKey } = await keyRes.json(); if (!publicKey) return false; const reg = await navigator.serviceWorker.ready;