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) <noreply@anthropic.com>
This commit is contained in:
parent
fef53fd003
commit
66b14cfa74
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user