Hi everyone,
I’m on Payload v3.49 and built a custom /verify endpoint that validates an email verification token and then creates a JWT for the user. I’m signing the JWT manually with jsonwebtoken using req.payload.secret.
The problem: subsequent authenticated requests return 403 Forbidden, which makes me think my JWT is not structured the way Payload expects.
Questions:
What is the correct way to generate a valid JWT?
Here’s a simplified version of my handler:
const jwt = require('jsonwebtoken');
const token = jwt.sign(
{
id: user.id,
collection: 'users',
},
req.payload.secret,
{ expiresIn: '30d' }
);