Hello, I am trying to setup Apple Server Notification Forwarding. I can verify that I am getting a notification forwarded to my api route, but I am having trouble parsing the response.
When I try to verify the signedPayload against the in-app-purhcase-key I always get the JONSWebTokenError.
The I am using the same .p8 key that I uploaded to revenue cat. Any suggestions?
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const signedPayload = req.body.signedPayload
console.log('the signed payload', req.body.signedPayload)
if (!signedPayload) {
return res
.status(400)
.json({ error: 'Signed payload not found in request body' })
}
// Verify and decode the signed payload using your App Store public key
// const publicKey =
// '-----BEGIN PRIVATE KEY----- *** my key ***
-----END PRIVATE KEY-----`
console.log('private key', privateKey)
let decodedPayload
try {
decodedPayload = jwt.verify(signedPayload, privateKey)
} catch (error) {
console.error('Error verifying signature:', error)
return res.status(403).json({ error: 'Invalid signature' })
}



